Writing to a file on server

B

Bishoy George

I want a link to a nice documentation about writing to a server file by C#
using System.IO; .
 
K

Ken Cox [Microsoft MVP]

Is it that the documentation sample is unsuitable:

http://msdn.microsoft.com/library/d...ef/html/frlrfsystemiotextwriterclasstopic.asp

using System;
using System.IO;

class TextRW
{
static void Main()
{
TextWriter stringWriter = new StringWriter();
using(TextWriter streamWriter =
new StreamWriter("InvalidPathChars.txt"))
{
WriteText(stringWriter);
WriteText(streamWriter);
}

TextReader stringReader =
new StringReader(stringWriter.ToString());
using(TextReader streamReader =
new StreamReader("InvalidPathChars.txt"))
{
ReadText(stringReader);
ReadText(streamReader);
}
}

static void WriteText(TextWriter textWriter)
{
textWriter.Write("Invalid file path characters are: ");
textWriter.Write(Path.InvalidPathChars);
textWriter.Write('.');
}

static void ReadText(TextReader textReader)
{
Console.WriteLine("From {0} - {1}",
textReader.GetType().Name, textReader.ReadToEnd());
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top