473,387 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Why open the text file first?

Hi all,

I was looking this evening for a quick sample of iterating through a text
file to read it in line by line...

I had already thrown something together myself which resembled the example,
but the main difference being that in my code I simply give the stream
reader the path to my file, where as in the example they opened the text
file, held it in an object, then fed that to the stream reader.

Can anyone advise why a) my way still works! b) whether its better to open
the text file first rather than doing what I'm doing.

Many thanks

Rob
Nov 18 '05 #1
4 1230
From docs:

File.OpenText Method

"This method is equivalent to StreamReader(String)."

HTH,
Greg

"Rob Meade" <ro********@NO-SPAM.kingswoodweb.net> wrote in message
news:q6*********************@news-text.cableinet.net...
Hi all,

I was looking this evening for a quick sample of iterating through a text
file to read it in line by line...

I had already thrown something together myself which resembled the
example,
but the main difference being that in my code I simply give the stream
reader the path to my file, where as in the example they opened the text
file, held it in an object, then fed that to the stream reader.

Can anyone advise why a) my way still works! b) whether its better to open
the text file first rather than doing what I'm doing.

Many thanks

Rob

Nov 18 '05 #2
"Greg Burns" wrote ...
From docs:

File.OpenText Method

"This method is equivalent to StreamReader(String)."


Hi Greg,

Many thanks for the reply.

So, my way is ok, and saves some code?

Regards

Rob
Nov 18 '05 #3
Rob Meade wrote:
"Greg Burns" wrote ...
From docs:

File.OpenText Method

"This method is equivalent to StreamReader(String)."


Hi Greg,

Many thanks for the reply.

So, my way is ok, and saves some code?


Sure. In a complex class library like the FCL, there's almost always more
than one way to get things done... or to shoot oneself in the foot ;-)

Cheers,

--
Joerg Jooss
jo*********@gmx.net
Nov 18 '05 #4
"Joerg Jooss" wrote ...
Sure. In a complex class library like the FCL, there's almost always more
than one way to get things done... or to shoot oneself in the foot ;-)


hehee, thats great, many thanks :o)

/beware of the foot shooting...

Regards

Rob
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric Pederson | last post by:
WryPyY's- I've come across this file operation in others' code and have not seen any documentation for it: the use of "t" in the mode of file opening, such as: f1=open(somefile, 'at')...
8
by: Asma | last post by:
Dear Sir, I am trying to find a way to open a Word document using C language and read the text of word doc into a variable. (Turbo C on Dos 6.0). Can anyone please tell me which libraries in...
2
by: Sin | last post by:
Hello everyone, I'm totally stumped at how little info I can find in MSDN or on the web concerning this. It's almost as if only microsoft personel hold the key to these secrets or something!!! ...
3
by: Mark.V.Sullivan | last post by:
I have encountered the same problem another posted about several months ago. Unfortunately, there was no result posted on the old thread. I will let the original message text stand and ask if...
22
by: fniles | last post by:
I have a .CSV file (comma delimited) that I want to open using OLEDB, but I get the error "External table is not in the expected format." If I save the .CSV file to an .XLS file, I can open the...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
1
by: sunnyluthra1 | last post by:
Hi Everyone, I am working on a piece of code, that displays the properties(Name, Datatype, size & Description) of the table in the database. Now I want to further Enhance the code. I Have created...
5
by: Ruben | last post by:
Hello, I am using the "Application.FollowHyperlink strFilePath, , True" line of code from within access forms to launch any file type I want (e.g., xls, doc, pdf, etc.). The files open up okay,...
2
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.