Why open the text file first?

R

Rob Meade

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
 
G

Greg Burns

From docs:

File.OpenText Method

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

HTH,
Greg
 
R

Rob Meade

...
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
 
J

Joerg Jooss

Rob said:
...


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,
 
R

Rob Meade

...
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 :eek:)

/beware of the foot shooting...

Regards

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top