• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7420
  • Last Modified:

c# write text file to network path

I try to use this below:
//write to file test
                            TextWriter tw = new StreamWriter("\\servername\test.txt");
                            tw.WriteLine("test1");
                            tw.Close();

I get illegal characters in path.

Thoughts?
0
mileyja
Asked:
mileyja
  • 2
1 Solution
 
Jaime OlivaresCommented:
TRY WITH:
TextWriter tw = new StreamWriter(@"\\servername\test.txt");
0
 
Jaime OlivaresCommented:
notice the backslash is a special character in c#, that's why the @ is used to disable it, also you can do as:
TextWriter tw = new StreamWriter("\\\\servername\\test.txt");
0
 
mileyjaAuthor Commented:
I will give this a try early next week when I am in the office and let you know.

Thanks,

Jamie
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now