Questions tagged [textwriter]

TextWriter is an abstract base within the .NET Framework, and represents a writer that can write a sequential series of characters.

73 questions
2
votes
3 answers

C# Windows Service Textwriter

I've created a standard windows service that uses the LocalSystem account. For the log files I use textwriter to write to a specified file within C:\Users\useraccount directory. The problem is, when running as a service under LocalSystem, it doesn't…
Goober
  • 211
  • 3
  • 9
2
votes
2 answers

MS Exam 70-536 Prep: Efficient use of TextWriter - The practice test answer is wrong (I think)!

I'm taking a practice test for the exam 70-536. Below is a screenshot. The yellow highlighted is what the exam says is the correct answer. The one with the radio button selected is the answer I thought it was. Note the explanation at the bottom…
richard
  • 12,263
  • 23
  • 95
  • 151
2
votes
5 answers

Save YamlStream from YamlDotNet Plugin to text file

I need to construct a YAML configuration file for a ROS node, inside a C# application. Basically, users specifies parameters values, and I fetch those values to write the YAML file. I'm developing on MonoDevelop with help of the great YamlDotNet…
2
votes
2 answers

Writing to log file: using (... new StreamReader) every time I write a line?

I have written an automation program with a start and a stop button, that does various tasks over and over, until user clicks stop. In the program I have several Console.WriteLines that shows the outcome of each little sub-task. I have decided to…
Magnus
  • 6,791
  • 8
  • 53
  • 84
2
votes
2 answers

How to write console output to a text file

I have this key generating algorithm made in C that will display all generated keys in console: So how can I save all the keys written to console to a text file? #include #include #include static const char alphabet[] =…
user3703308
  • 21
  • 1
  • 1
  • 2
2
votes
1 answer

Why do I get System.Collections.Generic.Dictionary`2 when writing to a StreamWriter?

I have this code: Console.Title = "System Reader"; Console.WriteLine("Enter the Domain-Address :"); string domain = Console.ReadLine(); Console.Clear(); string date =…
Erik Bender
  • 31
  • 1
  • 1
  • 5
1
vote
3 answers

Locking AppendAllText vs TextWriter

Regarding the preventing of "already in use" errors i want to ask if the first code snippet could potentialy be dangerous if called multiple times from multiple clients? Or are both code blocks equaly safe ? I am asking because the second…
HerbalMart
  • 1,669
  • 3
  • 27
  • 50
1
vote
6 answers

how to write file using streamwriter/textwriter/File?

I am able to write file when program is restarted(as it is always the first attempt of writing) but during the same execution it only works for the first time then after that it throws an exception stating The process cannot access file because it…
Aditya
  • 65
  • 10
1
vote
1 answer

When to call File.Dispose()

I am trying to use a text writer to write text to a file in .NET Core. The below code doesn't output anything to the file: TextWriter writer = File.CreateText(@"...txt"); writer.Write("Hello World"); However, this does: TextWriter writer =…
Harry Stuart
  • 1,781
  • 2
  • 24
  • 39
1
vote
1 answer

Copy single element of XML document being created by XMLWriter

My C# application has method that takes a list of objects (inputList) as parameter, it creates an XML string using the TextWriter and XMLWriter with the code below and submits to a webservice. using (TextWriter writer = new Utf8StringWriter()) { …
Daniel
  • 2,167
  • 5
  • 23
  • 44
1
vote
1 answer

ASP.NET - Infinite loop when using server.execute

When using server.execute to capture the html of the current page the following code gets stuck in an infinite loop. On Debug Server.Execute causes the button click event to fire each time. But why? It appears that preserveForm = true is maintaining…
DreamTeK
  • 32,537
  • 27
  • 112
  • 171
1
vote
1 answer

TextWriter and base folder files

I have added a text file to my project with intend of using it to contain strings taken from the form on the local page - I mean, you input the string into textfield, hit the button and the string is written with TextWriter into entries.txt just the…
user530809
  • 59
  • 1
  • 2
  • 5
1
vote
1 answer

C# write object to file in human-readable text

Do there exist any standard mechanisms or processes to output any C# object to file in human-readable text format ? Unlike serialization ( BinaryFormatter.Serializer ) this would not ever require reading back the object from file.
BaltoStar
  • 8,165
  • 17
  • 59
  • 91
1
vote
2 answers

TextWriter to TextBox

I have this TextWriter public static string txt = "./Logs.txt"; public static TextWriter Logs = File.CreateText(txt); I want to do something like this textBox1.Text = Logs.ToString(); or like this Logs.Flush(); textBox1.Text =…
Yox
  • 313
  • 2
  • 6
  • 18
1
vote
1 answer

Writing custom list using TextWriter

I have a class Author.cs as: public class Author { public Author() { } public int AuthorID; public string AuthorName; public List Papers; // ... rest of the methods... } and another class Paper.cs as:…
maliks
  • 1,102
  • 3
  • 18
  • 42