Solved

c# write text file to network path

Posted on 2008-06-11
3
6,994 Views
Last Modified: 2013-12-17
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
Comment
Question by:mileyja
  • 2
3 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 21761064
TRY WITH:
TextWriter tw = new StreamWriter(@"\\servername\test.txt");
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 21761077
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
 

Author Comment

by:mileyja
ID: 21842108
I will give this a try early next week when I am in the office and let you know.

Thanks,

Jamie
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now