Questions tagged [streamreader]

StreamReader is a C# class designed for character input in a particular encoding, it can be used for reading lines of information from a standard text file. By default, a StreamReader is not thread safe.

Implements a TextReader that reads characters from a byte stream in a particular encoding.

StreamReader is designed for character input in a particular encoding, whereas the Stream class is designed for byte input and output. StreamReader can be used for reading lines of information from a standard text file.

StreamReader defaults to UTF-8 encoding unless specified otherwise, instead of defaulting to the ANSI code page for the current system. UTF-8 handles Unicode characters correctly and provides consistent results on localized versions of the operating system. If you get the current character encoding using the CurrentEncoding property, the value is not reliable until after the first Read method, since encoding auto detection is not done until the first call to a Read method.

By default, a StreamReader is not thread safe. See TextReader.Synchronized for a thread-safe wrapper.

Official Microsoft documentation

1931 questions
0
votes
3 answers

Write text from text file to list c# windows phone

i am beginer and i don't know how to write from text file to list some strings. I mean i have a file : A B C D E F G H ... and i want to write it to list but i dont know how, maybe it is simple but i tried something and it doesnt work. Now i…
Karolina
  • 137
  • 3
  • 17
0
votes
0 answers

Reading an unfinished gzip file

I am creating a file using a cygwin bash script on remote: (echo $$ > tail.pid; exec tail -f -n+0 --retry FIX.log) | gzip -c >> /faraway/log.gz At the same time, on my local machine, I am reading /faraway/log.gz in c# using: txtFileReader = new…
ManInMoon
  • 6,795
  • 15
  • 70
  • 133
0
votes
2 answers

F# - Weird FileNotFound Exception

I basically just have this: open System.Net open System.IO let reader = new StreamReader("students.txt") let csv = reader.ReadToEnd() For some reason this throws a File Not Found Exception. It tells me it could not find the file at…
smritz
  • 108
  • 6
0
votes
1 answer

Adding text items from a csv file, to a listbox only when certain a string matches a string from that csv file

So I've been trying to figure out how to bring an entire line of a .csv file but only the ones who's first string matches another one. This is what I got so far, all im getting back in my listbox is info from the same random line. If you guys can…
0
votes
2 answers

Garbage value while reading HTML body using C#

I have below HTML file which contains content like below: ... ........ company's Chief Financial Officer. Now the....... ... I am reading the content of this file using: StringBuilder stringBuilder = new…
Aquarius24
  • 1,806
  • 6
  • 33
  • 61
0
votes
3 answers

How to read multilines from text file in c#

I have a text file which contains user records.In the text file one user record is present in three lines of text file.Now as per my requirement i have to read first three lines for one User, Process it and insert into database and next three lines…
Hansal Mehta
  • 185
  • 2
  • 4
  • 14
0
votes
1 answer

c# Remove a dynamically created checkbox based on a button click

I'm lost. I want to remove a value from a text file. The value is a checkbox.Name. I want to open a text file, find the corresponding username in the textfile, remove it and save the file based on a button click. Here is how I get the…
Frank Pytel
  • 127
  • 16
0
votes
1 answer

Read with StreamReader up to a certain string

I'm writing a file parser in a .NET application that reads the file with a StreamReader. The file to be parsed starts with a header that ends with "". I want to either read or ignore everything from the start until that string. The actual data…
ygoe
  • 18,655
  • 23
  • 113
  • 210
0
votes
0 answers

Client/Server have to alternate sending C#

As a side project, I'm working on a turn-based game. My plan was to simply send a string from one player to another describing the previous action taken. IE "Bob,MoveX,5,MoveY,3,END;" I have a simple program which sends strings back and forth, but…
0
votes
1 answer

1 dimension array to 2 dimension array

I am trying to create an application that reads a textfile with is formated like this : Outremont,3456,4370,15342,546 St-Leonard,6098,12765,10876,1024 Chapleau,6087,6087,6087,6087 It basically contains on each line a town name and 4 values that…
ThallForms
  • 87
  • 1
  • 7
0
votes
1 answer

To create new word document after replacing placeholder and maintain format as of old word document

I'm having following code,in this code i am reading the content of file as a stream, after reading it as stream I need to crate new document which will maintain the format after replacement of placeholder,if I m reading file from path it is…
shweta
  • 319
  • 2
  • 8
  • 21
0
votes
1 answer

Why won't the VB.NET function Hash and Download files from FTP Server using the given function?

So, I have a set of functions that run within a program that I designed, that acts as an integrity checker of sorts. This is the process behind it: It streams a text file from a remote FTP server, iterating through every line within the text file,…
0
votes
2 answers

Getting different values in a rectangular array when initialized from a text file

I'm trying to initialize a two-dimensional array from a text file containing a 20x20 grid of numbers (separated by spaces) using vb.NET in Visual Studio 2013. I've tweaked my loops to work correctly but the values I get from the streamreader are…
Paras
  • 253
  • 3
  • 16
0
votes
1 answer

Streamread section of text file to string

Using VB.NET. I am trying create a string of spatial coordinates for use as a parameter in querying a web service. The coordinates need to be extracted from a text file (a standard output from a GIS) which could be of any length. The web service…
benj
  • 113
  • 3
  • 11
0
votes
1 answer

iphone scanning a dat file for data

I am trying to remake a program I have made in C# in OBJ-C.In C# I used streamreader to search the data file for the line I am looking for then convert that line into a string that I can work with. I have looked at NSScanner but I'm not sure if…
Brodie
  • 3,526
  • 8
  • 42
  • 61