streamwriter
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.csharp.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

CJ (VIP)
Can one streamwriter object create dynamic files? in nested if statement?
example of code
Reply to this message...
 
    
Jon Skeet [C# MVP] (VIP)
CJ <Click here to reveal e-mail address> wrote:
[Original message clipped]

It would help if you could explain what you meant by "dynamic files".

--
Jon Skeet - <Click here to reveal e-mail address>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Reply to this message...
 
    
Morten Wennevik
Hi CJ,

What do you mean by dynamic files?
Having a StreamWriter reference you can certainly change it any time you want.

StreamWriter sw;

if(condition1)
    sw = new StreamWriter(param1);
else if(condition2)
    sw = new StreamWriter(param2);
else
    sw = new StreamWriter(param3);

--
Happy Coding!
Morten Wennevik [C# MVP]
Reply to this message...
 
    
CJ (VIP)
hello thanks to you!
but i get a read only error

"Morten Wennevik" wrote:

[Original message clipped]

Reply to this message...
 
    
Morten Wennevik
CJ,

If you get a read only error, then your parameter is either incorrect, the file is used by another program or another file handle in your own program.
If you reuse a StreamWriter remember to call Close() on it to release the current file before you use it on another file.

--
Happy Coding!
Morten Wennevik [C# MVP]
Reply to this message...
 
 
System.IO.StreamWriter




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com