开发者

Use Process.Start to execute a File on a Shared Folder

I'm trying to start a new Process by using Process.Start() which works great when I pass in

   Process.Start("C:\\Documents and Settings\\Upload.exe")

but is it possible to perform that same operation 开发者_StackOverflow社区when I move Upload.exe into a shared folder under My Network Places? I tried

   Process.Start("\\Shared Folder\\Upload.exe");

but I get a Win32Exception. Thanks for any information or suggestions in advance.


You should use UNC path for accessing a network resource. (Your file becomes a network resource when you place it in a shared path)

UNC path takes the following form.

\\ServerName\SharedPath\YourFile.exe

or

\\ServerName\D$\SharedPath\YourFile.exe

where D$ is the drive letter.

In your case you may have to use the following

Process.Start(@"\\Server-Name\Shared Folder\Upload.exe");

Use @ symbol in front of the string because your \\ will be treated as \, as an escape character.


Try either: "\\\\Shared Folder\\Upload.exe" or @"\\Shared Folder\Upload.exe"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜