🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #670

Re: 'File in use' error after File.Create()

#670
From: John Fowler
Date: Fri, 24 Sep 2004 06:03
30 lines
1568 bytes
Thanks, Joe... I get it!

John F.

Joe Mayo wrote:

> Hi John,
> 
> File.Create() opens a file stream, which you must close before accessing the
> file via a second stream.  Here are a couple options:
> 
>   using (File.Create("SomeFile3.txt")){}
> 
> or (which essentially means):
> 
>   FileStream fs = null;
> 
>   try
>   {
>    fs = File.Create("SomeFile3.txt");
>   }
>   finally
>   {
>    if (fs != null)
>    {
>     fs.Close();
>    }
>   }
> 
> Joe
Technical Details
Message-ID: <4153b8aa$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4152442d$1@newsgroups.borland.com> <415253dc$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,371711e74f47af5a
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Thu, 23 Sep 2004 23:03:28 -0700
From: John Fowler <jfowler@pXoXl.net>
Reply-To:  jfowler@pXoXlX.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax)
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.csharpbuilder.language.csharp
Subject: Re: 'File in use' error after File.Create()
References: <4152442d$1@newsgroups.borland.com> <415253dc$1@newsgroups.borland.com>
In-Reply-To: <415253dc$1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.20.189.226
Message-ID: <4153b8aa$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1096005802 24.20.189.226 (23 Sep 2004 23:03:22 -0700)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail