textwriter

Is there a TextWriter child class that fires event if text is written?

二次信任 提交于 2020-07-18 21:44:13
问题 I have written a method that accepts a TextWriter as an argument (Usually Console.Out, but not necessarily). When I call this method, some progress info is written to the TextWriter. However, since this method can run a long time, I want to update my UI with some status information. Currently, I am using a StringWriter but it does not have any events. So the first time I get a result from the StringWriter is after the method completed. Now I am searching for a class that inherits from

Out of Memory using TextWriter Stream with HttpWebRequest

江枫思渺然 提交于 2019-12-13 02:47:52
问题 Merged with How to free up memory after base64 convert. Thanks for your great suggestions to an OOM (out of memory) problem I'm seeing in code intended to stream files for web services. [I hope it is OK to start another thread which provides a bit more detail.] From the suggestions, I shrunk the buffer size used to read from the file, and it looks like memory consumption is better, but I'm still seeing an OOM problem, and I'm seeing this problem with files sizes as small as 5MB. I potentially

How can I write a text in GLUT? [duplicate]

早过忘川 提交于 2019-12-12 03:54:25
问题 This question already has answers here : How do I draw text with GLUT / OpenGL in C++? (4 answers) Closed 6 years ago . How can I write text in GLUT and C++? 回答1: Drawing 3D character You can follow this tutorials http://videotutorialsrock.com/opengl_tutorial/draw_text/home.php For 2D character You can draw bitmap character here is the example http://codeincodeblock.blogspot.com/2011/11/bitmap-is-rectangular-array-of-0s-and.html 来源: https://stackoverflow.com/questions/15843832/how-can-i-write

Writing Unix style text file in C#

北城余情 提交于 2019-11-29 13:27:03
I'm trying to write a text file with Unix-style newlines with my C# program. For some reason the following code doesn't work: TextWriter fileTW = ... fileTW.NewLine = "\n"; fileTW.WriteLine("Hello World!"); Neither does this: TextWriter fileTW = ... fileTW.Write("Hello World! + \n"); In both cases the '\n' is being replaced with '\r\n', which I don't want! I've been verifying this with a hex editor, which shows each line ending in 0x0D0A. Any ideas? Thanks! EDIT: Sorry everyone, false alarm! Allow me to explain... My TextWriter was writing to a MemoryStream, which was then being added to a tar

Writing Unix style text file in C#

不打扰是莪最后的温柔 提交于 2019-11-28 07:21:56
问题 I'm trying to write a text file with Unix-style newlines with my C# program. For some reason the following code doesn't work: TextWriter fileTW = ... fileTW.NewLine = "\n"; fileTW.WriteLine("Hello World!"); Neither does this: TextWriter fileTW = ... fileTW.Write("Hello World! + \n"); In both cases the '\n' is being replaced with '\r\n', which I don't want! I've been verifying this with a hex editor, which shows each line ending in 0x0D0A. Any ideas? Thanks! EDIT: Sorry everyone, false alarm!

Sharing violation IOException while reading and writing to file C#

此生再无相见时 提交于 2019-11-27 05:33:59
Here is my code: public static TextWriter twLog = null; private int fileNo = 1; private string line = null; TextReader tr = new StreamReader("file_no.txt"); TextWriter tw = new StreamWriter("file_no.txt"); line = tr.ReadLine(); if(line != null){ fileNo = int.Parse(line); twLog = new StreamWriter("log_" + line + ".txt"); }else{ twLog = new StreamWriter("log_" + fileNo.toString() + ".txt"); } System.IO.File.WriteAllText("file_no.txt",string.Empty); tw.WriteLine((fileNo++).ToString()); tr.Close(); tw.Close(); twLog.Close(); It throws this error: IOException: Sharing violation on path C:\Users

Sharing violation IOException while reading and writing to file C#

Deadly 提交于 2019-11-26 11:39:09
问题 Here is my code: public static TextWriter twLog = null; private int fileNo = 1; private string line = null; TextReader tr = new StreamReader(\"file_no.txt\"); TextWriter tw = new StreamWriter(\"file_no.txt\"); line = tr.ReadLine(); if(line != null){ fileNo = int.Parse(line); twLog = new StreamWriter(\"log_\" + line + \".txt\"); }else{ twLog = new StreamWriter(\"log_\" + fileNo.toString() + \".txt\"); } System.IO.File.WriteAllText(\"file_no.txt\",string.Empty); tw.WriteLine((fileNo++).ToString