Linked Questions

-3 votes
1 answer
2k views

Is there any Using.System command or anything else, to close the automatically StreamReader. I've been closing the StreamReader like this e.g.: sr.Close();
Kevin Garnick's user avatar
2 votes
1 answer
149 views

Is there ever a valid reason to use the Close method on a stream instead of Dispose?
Edd's user avatar
  • 702
1 vote
1 answer
107 views

I've come across some code like so: using (StreamReader myStream = new StreamReader(responseStream)) { response = myStream.ReadToEnd(); myStream....
Eric's user avatar
  • 3,289
1006 votes
21 answers
747k views

I'm writing a program in C# that needs to repeatedly access 1 image file. Most of the time it works, but if my computer's running fast, it will try to access the file before it's been saved back to ...
Dawsy's user avatar
  • 10.6k
455 votes
22 answers
1.3m views

I am trying to read a *.csv-file. The *.csv-file consist of two columns separated by semicolon (";"). I am able to read the *.csv-file using StreamReader and able to separate each line by using the ...
Rushabh Shah's user avatar
  • 4,611
65 votes
8 answers
45k views

If I have the following situation: StreamWriter MySW = null; try { Stream MyStream = new FileStream("asdf.txt"); MySW = new StreamWriter(MyStream); MySW.Write("blah"); } finally { if (...
JasonRShaver's user avatar
  • 4,414
8 votes
4 answers
20k views

I try to "wrap" a StreamReader in a class Fichier, with some extra methods and attributes. I want two things : The StreamReader opens automatically in the Fichier class; The StreamReader opens when ...
Chostakovitch's user avatar
10 votes
3 answers
17k views

I am pretty depressed by my programming knowledge but do we really need to dispose FileStream Object ? Reason I am asking is because code is throwing "File being used by another process" exception ...
Mathematics's user avatar
  • 7,688
6 votes
4 answers
785 views

If I have this: StreamWriter cout = new StreamWriter("test.txt"); cout.WriteLine("XXX"); // here IOException... StreamReader cin = new StreamReader("test.txt"); string text = cin.ReadLine(); the clr ...
xdevel2000's user avatar
  • 21.6k
1 vote
2 answers
2k views

I have a C# script which takes in two CSV files as input, combines the two files, performs numerous calculations on them, and writes the result in a new CSV file. These two input CSV file names are ...
user2673722's user avatar
0 votes
1 answer
2k views

Using the dotnet-cli (dotnet new, dotnet restore) with VScode, I made a new C# program. However, I can't seem to use the StreamReader properly. Here's the code. using System; using System.IO; ...
jlawcordova's user avatar
3 votes
2 answers
584 views

I'm writing an API that exports data to a Stream: public interface IExporter<in T> { Task ExportAsync(IEnumerable<T> inputs, Stream output); } Probably the various IExporter ...
aghidini's user avatar
  • 3,049
1 vote
1 answer
618 views

I've been trying to write this in order to list my folders , the append part doesn't work and it rewrites the whole thing , also if i try to list something else without exiting the app it gives the ...
Sina M.Azad's user avatar
-2 votes
2 answers
2k views

how do I add a path to a code where "HERE_HAS_TO_BE_A_PATH" is. When I do, Im getting an error message. The goal is to be able to specific the path where is the final text file saved. Thanks!...
Tomáš Sobek's user avatar
1 vote
2 answers
2k views

I have this method: public static string XmlSerialize<T>(T data) { string result; using (StringWriter stringWriter = new StringWriter()) { XmlWriterSettings settings = new ...
Lasoty's user avatar
  • 144

15 30 50 per page