Solved

c# write text file to network path

Posted on 2008-06-11
3
7,119 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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Object Oriented Programming, C#, referencing, scoping. 13 82
Problem with SelectList in .NET MVC application 1 34
Name Space error VS2015 1 35
Why use this lambda? 12 60
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

679 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