Solved

c# write text file to network path

Posted on 2008-06-11
3
7,192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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