|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
filestream?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? 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. -- Show quoteHide quoteJoseph Bittman Microsoft Certified Solution Developer Microsoft Most Valuable Professional -- DPM Blog/Web Site: http://CactiDevelopers.ResDev.Net/ "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? 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. >
Simple Eval() (Ithink) question
gradient titlebar in vbdotnet Print the RichTextBox IIF referencing both conditional parts regardless of condition? How to return value in Combobox Updating Files ListBox, ComboBox Bug??? Compiled HTML helpfile does not work when application is installed .NET how to check binary compatability Naming convention of Variables |
|||||||||||||||||||||||