Can not find a part of the path


Good morning everyone, again I need your support, since when trying to create a text file by means of C # and save it on a server, which I access by means of a network unit it generates this exception


Unable to find a part of the path   'C: \ \ c $ \ File'

The detail is that when sending it to my local disk C: \ File the file is created correctly, someone has an idea that it may be happening.

Thanks again for your support.

This is the code:

int nolines = 100;
string lines = "";
for (int i = 0; i <= nolines; i++)
      lines = "01-09-2016;01-09-2016;BANCO ;rfc1";
System.IO.StreamWriter filelocal = new System.IO.StreamWriter("c:\Archivo\test.tx");
System.IO.StreamWriter fileserver = new System.IO.StreamWriter("\\c$\Archivo\test.tx");//\\c$\Achivo
asked by Alberto Arenas 25.11.2016 в 18:54

1 answer


The problem is with this string:


You need another double \ in front:


or you can also use the text string literal with the symbol @ in front. This avoids the confusion with having to duplicate the \ :

answered by 25.11.2016 / 19:09