Click here to Skip to main content
15,915,867 members
Home / Discussions / C#
   

C#

 
GeneralRe: Finding the nearest value within a .txt file that is above another value Pin
suprsnipes8-Mar-10 21:32
suprsnipes8-Mar-10 21:32 
GeneralRe: Finding the nearest value within a .txt file that is above another value Pin
Calla8-Mar-10 22:02
Calla8-Mar-10 22:02 
QuestionWhich option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Nadia Monalisa8-Mar-10 15:55
Nadia Monalisa8-Mar-10 15:55 
AnswerRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Scott Dorman8-Mar-10 16:22
professionalScott Dorman8-Mar-10 16:22 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Nadia Monalisa8-Mar-10 17:24
Nadia Monalisa8-Mar-10 17:24 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn8-Mar-10 17:45
sitebuilderLuc Pattyn8-Mar-10 17:45 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
OriginalGriff8-Mar-10 22:37
mveOriginalGriff8-Mar-10 22:37 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Scott Dorman9-Mar-10 3:41
professionalScott Dorman9-Mar-10 3:41 
You're welcome. I think others have pretty much answered this question, but...

The "cost" of the extra method call is negligible, particularly when compared to the readability and safety concerns (it is entirely too easy to not properly wrap the StreamReader in a using statement.

That being said, you do need to consider the size of the file you are reading. Larger files will consume more memory in order to store the entire contents as a string. When C# 4 comes out, you can use the File.ReadLines method, which essentially does the same thing as ReadAllText or ReadAllLines except it returns an IEnumrable<string;>.
Scott Dorman
Microsoft® MVP - Visual C# | MCPD
President - Tampa Bay IASA

[Blog][Articles][Forum Guidelines]
Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

AnswerRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn8-Mar-10 16:25
sitebuilderLuc Pattyn8-Mar-10 16:25 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Nadia Monalisa8-Mar-10 17:28
Nadia Monalisa8-Mar-10 17:28 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn8-Mar-10 17:41
sitebuilderLuc Pattyn8-Mar-10 17:41 
AnswerRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
PIEBALDconsult8-Mar-10 17:41
mvePIEBALDconsult8-Mar-10 17:41 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn8-Mar-10 17:49
sitebuilderLuc Pattyn8-Mar-10 17:49 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
PIEBALDconsult9-Mar-10 3:20
mvePIEBALDconsult9-Mar-10 3:20 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn9-Mar-10 3:24
sitebuilderLuc Pattyn9-Mar-10 3:24 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
PIEBALDconsult9-Mar-10 6:16
mvePIEBALDconsult9-Mar-10 6:16 
GeneralRe: Which option is better for Reading file. File.ReadAllText(fileName) OR StreamReader Pin
Luc Pattyn9-Mar-10 6:33
sitebuilderLuc Pattyn9-Mar-10 6:33 
Questionhow could I print or save datagrid view records? Pin
ronakT8-Mar-10 7:46
ronakT8-Mar-10 7:46 
AnswerRe: how could I print or save datagrid view records?[modified] Pin
Dan Mos8-Mar-10 8:26
Dan Mos8-Mar-10 8:26 
AnswerRe: how could I print or save datagrid view records? Pin
Sandeep Mewara8-Mar-10 9:53
mveSandeep Mewara8-Mar-10 9:53 
AnswerRe: how could I print or save datagrid view records? Pin
David MacDermot8-Mar-10 10:08
David MacDermot8-Mar-10 10:08 
QuestionC# to control unicode bill printing in Dotmatrix printer Pin
Winmass8-Mar-10 7:43
Winmass8-Mar-10 7:43 
AnswerRe: C# to control unicode bill printing in Dotmatrix printer Pin
PIEBALDconsult8-Mar-10 11:47
mvePIEBALDconsult8-Mar-10 11:47 
AnswerRe: C# to control unicode bill printing in Dotmatrix printer Pin
98529322549-Mar-10 2:05
98529322549-Mar-10 2:05 
GeneralRe: C# to control unicode bill printing in Dotmatrix printer Pin
Winmass9-Mar-10 16:04
Winmass9-Mar-10 16:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.