Questions tagged [streamwriter]
StreamWriter is designed for character output in a particular encoding, whereas classes derived from Stream are designed for byte input and output.
streamwriter
1,530
questions
4
votes
1
answer
7k
views
Why does my StreamWriter Response output produce garbage accents in Excel but look fine in Notepad?
I'm using a technique from another Stack Overflow question to write a CSV file to the Response output for a User to Open/Save. The file looks good in Notepad, but when I open it in Excel the accented ...
7
votes
3
answers
3k
views
Power Loss after StreamWriter.Close() produces blank file, why?
Ok, so to explain; I am developing for a system that can suffer a power failure at any point in time, one point that I am testing is directly after I have written a file out using a StreamWriter. The ...
2
votes
3
answers
6k
views
StreamWriter won't flush to NetworkStream
Using a StreamWriter to write to a NetworkStream, and a StreamReader to read the response. The app is sending commands and reading responses to a news server.
Simplified code (sans error handling, ...
1
vote
5
answers
4k
views
StreamWriter not writing to an existing file
I am trying to write some text to the file using StreamWriter and getting the
path for the file from FolderDialog selected folder. My code works fine if the
file does not already exist. but if the ...
1
vote
3
answers
14k
views
Delete file using File.Delete and then using a Streamwriter to create the same file?
public void LoadRealmlist()
{
try
{
File.Delete(Properties.Settings.Default.WoWFolderLocation +
"Data/realmlist.wtf");
StreamWriter TheWriter =
new ...
7
votes
4
answers
9k
views
How I get the best performance out of .NET's StreamWriter in C#?
What is the recommended approach to get the best performance when we need to create text files bigger than 10 MB?
There are multiple sections in the code that need to write stuff to a single ...
47
votes
4
answers
154k
views
Writing file to web server - ASP.NET
I simply want to write the contents of a TextBox control to a file in the root of the web server directory... how do I specify it?
Bear in mind, I'm testing this locally... it keeps writing the file ...
0
votes
6
answers
12k
views
StreamWriter - Not appending to created file
I am using the StreamWriter object to write to either a file that is created by the constructor or already exists. If the file exists then it appends data. If not, then it should create a file and ...
29
votes
2
answers
29k
views
Do I need to do StreamWriter.flush()?
Suppose this C# code:
using (MemoryStream stream = new MemoryStream())
{
StreamWriter normalWriter = new StreamWriter(stream);
BinaryWriter binaryWriter = new BinaryWriter(stream);
...
1
vote
4
answers
3k
views
Streamwriter writes but gives web exception
I am trying to insert data via web service. The code below writes to the database; however, I have an error (see bottom). What goes wrong here? and how to fix it?
//Create the web request
...
1
vote
4
answers
2k
views
Why does the .NET Framework StreamReader / Writer default to UTF8 encoding?
I'm just looking at the constructors for StreamReader / Writer and I note it uses UTF8 as default. Anyone know why this is? I would have presumed it would have been a safer bet to default to Unicode.
1
vote
4
answers
4k
views
Why doesn't StreamWriter work in a Windows Service?
I have this simple code that records appends a log to a text file:
public static void RecordToFile(string filename, Log log)
{
TextWriter textWriter = new StreamWriter(Constants....
3
votes
4
answers
3k
views
Having problem opening/writing to a text file in ASP.NET
I want to write some stats to a text file every time a person loads a page. But every once in awhile I am getting at 'Could Not Open File, Already in use' type of error. I can not 100% replicate ...
1
vote
2
answers
1k
views
Started Process from .NET but RedirectedStandardOutput doesn't support UTF-8
I am trying to call php's HTML purifier from .NET using this code:
Process myProcess = new Process();
myProcess.StartInfo.FileName = "C:\Path\to\php.exe";
myProcess.StartInfo.Arguments = ...
44
votes
4
answers
51k
views
Redirect .NET StreamWriter output to a String variable
I'd like to know if it is possible to redirect StreamWriter output to a variable
Something like
String^ myString;
StreamWriter sw = gcnew StreamWriter([somehow specify myString])
sw->WriteLine("...