System.Diagnostics.Process仅挂起网络文件

时间:2013-10-31 16:15:37

标签: vb.net visual-studio-2012 process system.diagnostics

Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()

myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.FileName = "C:\Program Files (x86)\IrfanView\i_view32.exe"
myProcess.StartInfo.Arguments = sFileName
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()

当文件在本地驱动器上时,上面用于在Irfanview中打开tif图像的代码可以正常工作。如果文件在网络共享上,Irfanview似乎在标题栏中挂起(无响应)。这是Windows 7的新行为。在Windows XP计算机上,在同一网络上,我没有这个问题。

知道为什么吗?

格雷格

[编辑]

我也尝试了下面的代码没有运气,并尝试在irfanview旁边的另一个图像查看器,并得到相同的结果。使用此代码,irfanview告诉我它不是有效文件,并显示文件的确切路径和文件名。很烦人。旧的Windows API ShellExecute将不会启动该程序。 Grrrrrr !!!!

Dim domain As String = {domain}
Dim uname As String = {username}
Dim passwordtx As String = {password}
Dim password As New System.Security.SecureString()
Dim c As Char
For Each c In passwordtx
    password.AppendChar(c)
Next c

Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()

myProcess.StartInfo.UseShellExecute = True
myProcess.StartInfo.FileName = "C:\Program Files (x86)\IrfanView\i_view32.exe"
myProcess.StartInfo.Arguments = sFileName
myProcess.StartInfo.WorkingDirectory = "C:\"
myProcess.StartInfo.UserName = uname
myProcess.StartInfo.Domain = domain
myProcess.StartInfo.Password = password
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal
myProcess.Start()

1 个答案:

答案 0 :(得分:1)

它与代码无关。问题是文件夹中有太多文件,irfanview试图将它们全部编目,或做类似的事情。我需要按月拆分文件。

格雷格