Re: Process used by another

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Steve Walker" <steve@xxxxxxxxxxxxxxxxxxx> wrote in message
news:o3pPitQBZicCFwVS@xxxxxxxxxxxxxxxxxxxxxx
> In message <OXI8tPLTFHA.3012@xxxxxxxxxxxxxxxxxxxx>, "Willy Denoyette
> [MVP]" <willy.denoyette@xxxxxxxxxx> writes
>>
>>"Josema" <Jestrade@xxxxxxx> wrote in message
>>news:C8AB57B7-74AD-4ED0-8364-3419DC27E1F2@xxxxxxxxxxxxxxxx
>>> Hi,
>>>
>>> i have a Web application and i get this error:
>>>
>>> The process cannot access the file
>>> "c:\inetpub\wwwroot\dotnet\Soluciones\Calculations\PhoneTariffs\Errors\
>>>Log.txt"
>>> because it is being used by another
>>>
>>> The code that generates this error is the following:
>>>
>>> Directory.CreateDirectory("c:\inetpub\wwwroot\Error");
>>> File.Create("c:\inetpub\wwwroot\Error\log.txt");
>>>
>>> System.IO.StreamWriter StreamLog=new
>>> System.IO.StreamWriter("c:\inetpub\wwwroot\Error\log.txt");
>>> StreamLog.Write(e.Message);
>>> StreamLog.Close();
>
>>You open the same file two times here.
>>There is no need for - File.Create("c:\inetpub\wwwroot\Error\log.txt");
>
> And the StreamWriter created by that line of code is still open, which is
> probably what is locking the file.
>
> --
> Steve Walker

Exactly!

Willy.


.



Relevant Pages

  • Re: Atomicity Question
    ... > preferred route) always access shared data from within a lock. ... Hmm... ... I'm beginning to see why you prefer to always use locking. ... Prev by Date: ...
    (microsoft.public.dotnet.framework)
  • Re: HP 7410 setup
    ... Hopefully HP replacement will get past installing ink cartridges ... without locking up. ... Prev by Date: ...
    (comp.sys.hp.hardware)
  • Re: 2 users 1 record
    ... look up reference material on pessimistic & optimistic locking... ... HTH ... Prev by Date: ...
    (microsoft.public.access.formscoding)
  • Irony
    ... Subject: DELIVERY FAILURE: Recipient user name postmaster ... Several matches found in Domino Directory. ... Steve Walker ... Prev by Date: ...
    (uk.misc)
  • Re: Lawyer: "She is too pretty to be in prison"
    ... performing a public and societal service. ... They are locking up the ... Prev by Date: ...
    (soc.women)