【发布时间】:2013-12-28 04:46:21
【问题描述】:
我正在尝试在 Visual Basic 中做一个简单的 Windows 窗体应用程序,它使用 shell() 更改驱动器中所有文件的属性。
它可以工作,但由于有时有很多文件,应用程序看起来像冻结(因为我使用“等待”参数为真。
所以我正在寻找一种在 cmd 执行操作时显示“加载”gif 的方法,我在 msdn 中找到了一个示例,使用interaction.Start (http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.interaction.shell(v=vs.110).aspx) 来“等待进程完成”我尝试将 shell 与该示例混合,但无法正常运行。
这是我目前的代码。
pic_working.Visible = True
myDrive = "F:\"
Dim procID As Integer
Dim newProc As Diagnostics.Process
newProc = Diagnostics.Process.GetProcessById(Shell("cmd.exe /C attrib -r " + myDrive + "*.* /s /d", AppWinStyle.NormalFocus, False))
procID = newProc.Id
Dim procEC As Integer = -1
If newProc.HasExited Then
procEC = newProc.ExitCode
End If
MsgBox("Process with ID " & CStr(procID) & " terminated with exit code " & CStr(procEC))
myDrive =""
pic_working.Visible = False
它可以工作...有点...当我将 shell() 的等待参数设置为“真”时,完成任务需要大约 30 秒(在我的试驾中),但它只是假的跳过所有内容,我的 pic_Working 从未显示。
您能给我一个提示吗...可以这样做,或者我必须做很长的路(使用File.SetAttributes并当时解析一个文件?
谢谢!
【问题讨论】:
标签: vb.net visual-studio shell