Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

accessing over network path

Tags:

c#

path

I try to create a file in a server using the following code

String path = @"\\192.1.1.55\\d$:\\Scripts\\list.txt";
using (File.Create(path));
richTextBox1.SaveFile(path, RichTextBoxStreamType.PlainText);

It gives System.NotSupportedException The given path's format is not supported.

I also tried

String path = "\\\\192.1.1.55\\d$:\\Scripts\\list.txt";
using (File.Create(path));
richTextBox1.SaveFile(path, RichTextBoxStreamType.PlainText);

I need to create files and access them over the network with the ip of the server that has files,

like image 951
user3880883 Avatar asked Oct 24 '25 18:10

user3880883


2 Answers

Share some folder on server, for example Scripts and use this path:

String path = @"\\192.1.1.55\Scripts\list.txt";
like image 130
Backs Avatar answered Oct 27 '25 09:10

Backs


Remove the : after the D$ and it should work.

I now realized that you also have an @ at the beginning of the path string, therefore, change the path to this:

String path = @"\\192.1.1.55\d$\Scripts\list.txt";

A better approach would be to map the network path to a drive and to use that while saving.

For instance, map network drive R (for richtextbox) to \\192.1.1.55\d$, then change your path variable to G:\Scripts\list.txt

like image 30
Oguz Ozgul Avatar answered Oct 27 '25 09:10

Oguz Ozgul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!