Home All Groups Group Topic Archive Search About
Author
13 Sep 2006 9:02 PM
cj
VB2005

I've opened files and read them using

r = new io.streamreader("c:\thisfile.txt")
line = r.readline

Now I see an example where they are doing
dim objopenfile as io.filestream = new io.filestream(filename,
io.filemode.open, io.fileaccess.read, io.fileshare.read)
dim objstreamreader as io.streamreader = new io.streamreader(objopenfile)
textbox1.text=objstreamreader.readtoend()

What is filestream and why would I want to use it?

Author
13 Sep 2006 9:33 PM
Joseph Bittman MVP MCSD
Sept. 13, 2006

  Creating a new streamreader and providing a file name just creates a new
stream to the file. If you create a filestream yourself and then pass it to
the streamreader, you will get more options... like whether to only open the
file for Reading, or only for Writing.

At times, your user account may only have Read or Write NTFS privileges to a
file... and opening a stream directly through a reader/writer may demand
both privileges because it doesn't know what you will be doing.

Just a matter of options... I don't think there's probably a performance
difference.

--

                       Joseph Bittman
     Microsoft Certified Solution Developer
Microsoft Most Valuable Professional -- DPM

Blog/Web Site: http://CactiDevelopers.ResDev.Net/
Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:%235887f31GHA.968@TK2MSFTNGP03.phx.gbl...
> VB2005
>
> I've opened files and read them using
>
> r = new io.streamreader("c:\thisfile.txt")
> line = r.readline
>
> Now I see an example where they are doing
> dim objopenfile as io.filestream = new io.filestream(filename,
> io.filemode.open, io.fileaccess.read, io.fileshare.read)
> dim objstreamreader as io.streamreader = new io.streamreader(objopenfile)
> textbox1.text=objstreamreader.readtoend()
>
> What is filestream and why would I want to use it?
Author
14 Sep 2006 3:00 PM
cj
Thank you.  I think I understand now.

Joseph Bittman MVP MCSD wrote:
Show quoteHide quote
> Sept. 13, 2006
>
>  Creating a new streamreader and providing a file name just creates a
> new stream to the file. If you create a filestream yourself and then
> pass it to the streamreader, you will get more options... like whether
> to only open the file for Reading, or only for Writing.
>
> At times, your user account may only have Read or Write NTFS privileges
> to a file... and opening a stream directly through a reader/writer may
> demand both privileges because it doesn't know what you will be doing.
>
> Just a matter of options... I don't think there's probably a performance
> difference.
>