Inline.

On 18 May 2010 16:13, Maddin, Peter <[email protected]> wrote:
<snip>
> I just noticed they had (although they might deny it now that I have been 
> working on it).
>
>                originalFileName = String.Empty;
>                using (var csv = new CsvReader(new StreamReader(fileName), 
> true, Delimitor))
>                {
>
> That does not look right. The filestream will never be closed (at least I 
> don't think so)

It should be if CsvReader is based on the TextReader family of classes
(CsvReader doesn't seem to be a class in the BCL). I'm assuming this
given the naming scheme.

Actually, just found the what I think is the CsvReader class being
used [1]. Given he claims it follows StreamReader's design closely,
I'd say that line of code will be fine because StreamReader (actually,
the abstract base class TextReader) dictates that calling close()
"Closes the StreamReader object *and the underlying stream*, and
releases any system resources associated with the reader." [2]
(emphasis mine)

I'd take a look at the source code, but cbf signing up at CodeProject.
Also, he uses that using statement in his examples :)

[1] - http://www.codeproject.com/KB/database/CsvReader.aspx
[2] - 
http://msdn.microsoft.com/en-us/library/system.io.streamreader.close(v=VS.100).aspx

> I have changed this to
>
>            originalFileName = String.Empty;
>            // open the file. It is expected to be a CSV file with headers
>            using (var sr = new StreamReader(fileName))
>            {
>                using (var csv = new CsvReader(sr, true, Delimitor))
>                {
>
> I will try this out after another reboot.
>
> I will also try out the Directory.GetLogicalDrives();
> If the above does not achieve anything.
>
>
> Regards Peter Maddin
> Applications Development Officer
> PathWest Laboratory Medicine WA
> Phone : +618 9473 3944
> Fax : +618 9473 3982
> E-Mail : [email protected]
> The contents of this e-mail transmission outside of the WAGHS network are 
> intended solely for the named recipient's), may be confidential, and may be 
> privileged or otherwise protected from disclosure in the public interest. The 
> use, reproduction, disclosure or distribution of the contents of this e-mail 
> transmission by any person other than the named recipient(s) is prohibited. 
> If you are not a named recipient please notify the sender immediately.
>
>
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On 
> Behalf Of silky
> Sent: Tuesday, 18 May 2010 1:26 PM
> To: ozDotNet
> Subject: Re: DriveInfo.GetDrives() not returning
>
> On Tue, May 18, 2010 at 1:53 PM, Maddin, Peter
> <[email protected]> wrote:
>
> [...]
>
>> I am targeting .NET 3.5. Is it a framework problem, driver problem, some
>> other problem?
>>
>> Could it just be the machine I am using?
>
> I know its boring but can you reproduce it in a stand-alone app? (not
> part of your main one?)
>
> My guess would be you're somehow in a lock with yourself.
>
>
>> Regards Peter Maddin
>> Applications Development Officer
>> PathWest Laboratory Medicine WA
>> Phone : +618 9473 3944
>> Fax : +618 9473 3982
>> E-Mail : [email protected]
>> The contents of this e-mail transmission outside of the WAGHS network are
>> intended solely for the named recipient's), may be confidential, and may be
>> privileged or otherwise protected from disclosure in the public interest.
>> The use, reproduction, disclosure or distribution of the contents of this
>> e-mail transmission by any person other than the named recipient(s) is
>> prohibited. If you are not a named recipient please notify the sender
>> immediately.
>
> --
> silky
>
>  http://www.programmingbranch.com/
>

Reply via email to