Why open the text file first?

  • Thread starter Thread starter Rob Meade
  • Start date Start date
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
 
From docs:

File.OpenText Method

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

HTH,
Greg
 
...
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
 
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,
 
...
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
 
Back
Top