开发者

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

开发者 https://www.devze.com 2023-03-18 20:36 出处:网络
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\")

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

精彩评论

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