Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Streamwriter issue with remote machine - network name cannot be found

I am trying to create a file on the remote machine but I am getting this error:

The network name cannot be found

I checked the network path and I was able to access the path from my machine. Could you please let me know what could be wrong?

Here is my code:

using (StreamWriter sw = new StreamWriter("\\\\servername\\TEST1\\TEST\\NEWFILE.csv", true)) {
    sw.WriteLine(sw);
}
like image 324
nav100 Avatar asked Oct 29 '25 16:10

nav100


2 Answers

Go to \\servername\TEST1 and give write permission to the user or ASP.NET (if you have a web application) on the test folder and then re-run your program, and it will work.

To give write permissions, just refer to this article:
How to share a folder/File

In case it still does not work, try replacing the server name with the server IP address and do the same as stated above.

like image 131
ajaysinghdav10d Avatar answered Nov 01 '25 05:11

ajaysinghdav10d


Give the access rights to the user under which this application runs either it is a IIS pool or windows service etc

like image 20
Dave Avatar answered Nov 01 '25 06:11

Dave