|
-
Jun 19th, 2006, 02:15 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2.0] FileStream object why ???
In order to read and write to a sequential file, I am using Streamreader and streamwriter classes. and it works fine.
In a book which I am going thru, first a "FileStream" object is created.
why do I need a "FileStream" object?
thanks
nath
-
Jun 19th, 2006, 02:20 PM
#2
Thread Starter
Hyperactive Member
Re: [2.0] FileStream object why ???
I meant for example:
FileStream stmWeekdays = new FileStream("Weekdays.txt", FileMode.Create, FileAccess.Write, FileShare.None);
StreamWriter stmWriter = new StreamWriter(stmWeekdays);
why can't I pass the path name of the file while creating stmWriter object.
I don't understand the benefit of using FileStream object.
thanks
nath
-
Jun 19th, 2006, 05:30 PM
#3
Re: [2.0] FileStream object why ???
You can pass the name of the file. The thing is, you need a FileStream regardless. If you pass the name of the the file to the StreamReader or StreamWriter constructor then it simply creates the FileStream for you. A reference to that FileStream can then be retrieved through the BaseStream property.
-
Jun 19th, 2006, 05:37 PM
#4
Thread Starter
Hyperactive Member
Re: [2.0] FileStream object why ???
Hello jm,
could you give me an example with brief explanation ?
thank you so much
nath
-
Jun 19th, 2006, 05:37 PM
#5
Re: [2.0] FileStream object why ???
Books don't specify the best way to do things (Not so often)
They aim to using as much classes as possible so you learn their usability
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 19th, 2006, 05:53 PM
#6
Re: [2.0] FileStream object why ???
If you want an example then go to the MSDN library. The topic for each StreamWriter constructor has the same code example that shows how to use each of them. MSDN should always be your first stop.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|