Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

process

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 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.

like image 562
aahrens Avatar asked Dec 12 '22 11:12

aahrens


1 Answers

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.

like image 196
SaravananArumugam Avatar answered Feb 25 '23 18:02

SaravananArumugam