>>Hi All,
>>
>>Just checking, is this a valid way to use the using statement in this case? Is the StreamWriter closed and disposed?
>
>Yes. A "using" statement ends up being compiled as (essentially, not exactly):
>
>
>try
>{
> stream = File.Open(deleteListPath, FileMode.Open)
>}
>finally
>{
> stream.Dispose();
>}
>
>
>I also just took a look at the Stream base class inside of Reflector and Close() basically does this:
>
>
>this.Dispose(true);
>GC.SuppressFinalize(this);
>
>
>So a call to both Close and Dispose turns out to not be necessary. One or the other is fine.
Perfect that answered two questions in one. What I found interesting was I had to define the FileStream as null first.
I had to do this.
FileStream stream = null
using (stream = File.Open(deleteListPath, FileMode.Open))
I first tried to do this but it wouldn't work.:
using(FileStream stream = File.Open(deleteListPath, FileMode.Open))
Tim
Timothy Bryan