Can not find a part of the path

3

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: \ 172.69.17.30 \ 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("\172.69.17.30\c$\Archivo\test.tx");//\172.69.17.30\c$\Achivo
filelocal.WriteLine(lines);
filelocal.Close();
fileserver.WriteLine(lines);
fileserver.Close();
    
asked by Alberto Arenas 25.11.2016 в 18:54
source

1 answer

4

The problem is with this string:

"\172.69.17.30\c$\Archivo\test.tx"

You need another double \ in front:

"\\172.69.17.30\c$\Archivo\test.tx"

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

@"\172.69.17.30\c$\Archivo\test.tx"
    
answered by 25.11.2016 / 19:09
source