Re: error creating/writing to log file...strange problem!
From: Milsnips (milsnips_at_hotmail.com)
Date: 02/07/05
- Next message: Sergey Bogdanov: "Re: error creating/writing to log file...strange problem!"
- Previous message: Gizmo: "Using WM_LBUTTONUP"
- In reply to: Doug Forster: "Re: error creating/writing to log file...strange problem!"
- Next in thread: Sergey Bogdanov: "Re: error creating/writing to log file...strange problem!"
- Reply: Sergey Bogdanov: "Re: error creating/writing to log file...strange problem!"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 7 Feb 2005 12:19:36 +0100
this is the code i was using....
If Not IO.File.Exists(AppPath & "\log.txt") Then IO.File.Create(AppPath &
"\log.txt")
Dim f As IO.StreamWriter = IO.File.AppendText(AppPath & "\log.txt")
it crashes on the second line.
regards,
Paul
"Doug Forster" <doug_ZAPTHIS_AT_ZAPTHIS_TONIQ_DOT_CO_DOT_NZ> wrote in
message news:OsDCNZiCFHA.1188@tk2msftngp13.phx.gbl...
> Hi,
>
> You seem to think that there is a timing issue involved. This is most
> unlikely. The file will have been locked because your code left it locked.
> i.e. you failed to close the file. Though you have solved your problem you
> need to show us some code if you want to know why you have solved it.
>
> Cheers
>
> Doug Forster
>
> "Milsnips" <milsnips@hotmail.com> wrote in message
> news:e8hwVOfCFHA.1396@TK2MSFTNGP14.phx.gbl...
>> yes thats the problem.. i moved the code to create the log file at
>> opening the app, and problem doesnt appear anymore.
>>
>> Is there anyway that i could make it wait until the process has unlocked
>> the file and then continue?
>> thanks,
>>
>> Paul
>> "Peter Foot [MVP]" <feedback@nospam-inthehand.com> wrote in message
>> news:uVQjlLfCFHA.3732@TK2MSFTNGP14.phx.gbl...
>>> Can you post a code snippet showing the problem? The exception is most
>>> likely if the file is still locked when you try to open it.
>>>
>>> Peter
>>>
>>> --
>>> Peter Foot
>>> Windows Embedded MVP
>>> www.inthehand.com | www.opennetcf.org
>>>
>>> "Milsnips" <milsnips@hotmail.com> wrote in message
>>> news:O34kAkeCFHA.2620@tk2msftngp13.phx.gbl...
>>>>i have a function that checks for a log file, if not exists then it
>>>>creates
>>>> it, then opens it and writes a error log.
>>>>
>>>> the problem is, first time it calls the event and the file does not
>>>> exist,
>>>> it creates it okay, but when it tries to open it straight after that,
>>>> it
>>>> throws an IOException.
>>>> If i close the app, then re-open and add another log to the existing
>>>> file,
>>>> it works okay??
>>>>
>>>> any help appreciated,
>>>>
>>>> thanks,
>>>> Paul
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>
- Next message: Sergey Bogdanov: "Re: error creating/writing to log file...strange problem!"
- Previous message: Gizmo: "Using WM_LBUTTONUP"
- In reply to: Doug Forster: "Re: error creating/writing to log file...strange problem!"
- Next in thread: Sergey Bogdanov: "Re: error creating/writing to log file...strange problem!"
- Reply: Sergey Bogdanov: "Re: error creating/writing to log file...strange problem!"
- Messages sorted by: [ date ] [ thread ]