VB.NET 怎样复制目录文件夹

ybvresn 2010-11-03 10:31:40
VB.NET 怎样复制目录文件夹
我用FILE.COPY 复制说不能复制 那用API 怎样实现呢 希望各位大哥能及时出来解决一下问题
谢谢

还有就是小弟希望各位大哥在提供一个RAR 的解类
...全文
718 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ybvresn 2010-11-04
  • 打赏
  • 举报
回复
objArguments = " X " & " -P- " & filepath & " -Y- " + " -O+ " + WorkingDirectory
我是这样处理但还是不能正确加压文佳到正常路径 Application.StartupPath 获取的路径我没有处理对吗?
那个大哥出来帮一下忙吧!谢谢了啊
ybvresn 2010-11-04
  • 打赏
  • 举报
回复
怎么处理啊 给点代码行吗
yanlongwuhui 2010-11-04
  • 打赏
  • 举报
回复
执行程序放在桌面时Application.StartupPath取到的路径中有空格,你需要对UnRar中的WorkingDirectory 做下处理
兔子-顾问 2010-11-03
  • 打赏
  • 举报
回复
我空间中有
ybvresn 2010-11-03
  • 打赏
  • 举报
回复
逍遥 留个来你系方式行吗
ybvresn 2010-11-03
  • 打赏
  • 举报
回复
Private Sub UnRar(ByVal WorkingDirectory As String, ByVal filepath As String)

' Microsoft.Win32 and System.Diagnostics namespaces are imported

Dim objRegKey As RegistryKey
objRegKey = Registry.ClassesRoot.OpenSubKey("WinRAR\Shell\Open\Command")
' Windows 7 Registry entry for WinRAR Open Command

Dim obj As Object = objRegKey.GetValue("")

Dim objRarPath As String = obj.ToString()
objRarPath = objRarPath.Substring(1, objRarPath.Length - 7)

objRegKey.Close()

Dim objArguments As String
' in the following format
' " X G:\Downloads\samplefile.rar G:\Downloads\sampleextractfolder\"
objArguments = " X " & " " & filepath & " " + " " + WorkingDirectory

Dim objStartInfo As New ProcessStartInfo()
' Set the UseShellExecute property of StartInfo object to FALSE
' Otherwise the we can get the following error message
' The Process object must have the UseShellExecute property set to false in order to use environment variables.
objStartInfo.UseShellExecute = False
objStartInfo.FileName = objRarPath
objStartInfo.Arguments = objArguments
objStartInfo.WindowStyle = ProcessWindowStyle.Hidden
objStartInfo.WorkingDirectory = WorkingDirectory & "\"

Dim objProcess As New Process()
objProcess.StartInfo = objStartInfo
objProcess.Start()

End Sub


调用UnRAR(Application.StartupPath, "C:\WYGJ.rar") 如果我把执行程序放在桌面解压就报错 WYGJ.RAR 没有被解压 我把程序放在其他盘符里 就正常运行这是怎么回事呢?
ybvresn 2010-11-03
  • 打赏
  • 举报
回复
参数“showUI”(-1)的值对于枚举类型“UIOption”无效。
参数名: showUI

My.Computer.FileSystem.CopyDirectory("c:\222", "D:\111", True, FileIO.UICancelOption.DoNothing)
兔子-顾问 2010-11-03
  • 打赏
  • 举报
回复
看到了。最后一个参数去掉不要就好了。
My.Computer.FileSystem.CopyDirectory("原目录", "目标目录", True)

ybvresn 2010-11-03
  • 打赏
  • 举报
回复
true表示允许覆盖,后面的表示用户点取消时不提示异常
My.Computer.FileSystem.CopyDirectory("原目录", "目标目录", True, FileIO.UICancelOption.DoNothing)

要报错啊
兔子-顾问 2010-11-03
  • 打赏
  • 举报
回复
解压rar
http://www.example-code.com/vbdotnet/rar_unrar.asp
http://www.kodyaz.com/articles/how-to-unrar-rar-files-using-vb.net-extract-code.aspx
兔子-顾问 2010-11-03
  • 打赏
  • 举报
回复
目录复制
'true表示允许覆盖,后面的表示用户点取消时不提示异常
My.Computer.FileSystem.CopyDirectory("原目录", "目标目录", True, FileIO.UICancelOption.DoNothing)

16,718

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧