Search code examples
c#streamwriter

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);
}

Solution

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