Board index » delphi » Help with file creation and deletion...

Help with file creation and deletion...

If have two simple procedures..

                Begin
                        FileCreate('newfile.txt');
                        FileListBox1.Update;
                End;

and.....

                Begin
                        DeleteFile('newfile.txt');
                        FileListBox1.Update;
                End;

        Assuming nothing else is done. (I'm never opening the file just
creating it) How come the DeleteFile won't work?

        Thanks - Joe

 

Re:Help with file creation and deletion...


Make sure you're in the right directory.  Try passing the filename and path
to DeleteFile.

Quote
Joe Wirtz wrote:
> If have two simple procedures..

>                 Begin
>                         FileCreate('newfile.txt');
>                         FileListBox1.Update;
>                 End;

> and.....

>                 Begin
>                         DeleteFile('newfile.txt');
>                         FileListBox1.Update;
>                 End;

>         Assuming nothing else is done. (I'm never opening the file just
> creating it) How come the DeleteFile won't work?

>         Thanks - Joe

Re:Help with file creation and deletion...


Make sure you're in the right directory.  Try passing the filename and path
to DeleteFile.

Quote
Joe Wirtz wrote:
> If have two simple procedures..

>                 Begin
>                         FileCreate('newfile.txt');
>                         FileListBox1.Update;
>                 End;

> and.....

>                 Begin
>                         DeleteFile('newfile.txt');
>                         FileListBox1.Update;
>                 End;

>         Assuming nothing else is done. (I'm never opening the file just
> creating it) How come the DeleteFile won't work?

>         Thanks - Joe

Re:Help with file creation and deletion...


These are two calls that my program needs to make getting the file name
from user input. It WILL work if I try to delete a file after just starting
the app.

If I create a new file, without quiting, then the delete does not work. I need
to quit the app then restart to be able to delete the file.

Seems like delphi 3 thinks the files open or something??? Yet it won't
let me 'close' it either.

In article <355237F4.C5D71...@takeoff1.com>, Justin Ogilby

Quote
<jus...@takeoff1.com> wrote:
>Make sure you're in the right directory.  Try passing the filename and path
>to DeleteFile.

>Joe Wirtz wrote:

>> If have two simple procedures..

>>                 Begin
>>                         FileCreate('newfile.txt');
>>                         FileListBox1.Update;
>>                 End;

>> and.....

>>                 Begin
>>                         DeleteFile('newfile.txt');
>>                         FileListBox1.Update;
>>                 End;

>>         Assuming nothing else is done. (I'm never opening the file just
>> creating it) How come the DeleteFile won't work?

>>         Thanks - Joe

Re:Help with file creation and deletion...


Are you turning I/O check {$I-} off somewhere? If you are, I think that even the
modern Delphi (pascal) versions require you to make this test also:
 if IOResult = 0.
Without using it, the next IO-operation seems to get lost somewhere.

Markku Nevalainen

Quote
Joe Wirtz wrote:

> If have two simple procedures..

>                 Begin
>                         FileCreate('newfile.txt');
>                         FileListBox1.Update;
>                 End;

> and.....

>                 Begin
>                         DeleteFile('newfile.txt');
>                         FileListBox1.Update;
>                 End;

>         Assuming nothing else is done. (I'm never opening the file just
> creating it) How come the DeleteFile won't work?

>         Thanks - Joe

Other Threads