LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I can't delete an existing file.

Hi.
First of all in my project I create a file and I use it to deposit my data. Now I must delete the file but I get an error (-6) that the acces to file is denied.

The funtions that I use are:
OpenFile (FileName, VAL_READ_WRITE,VAL_OPEN_AS_IS, VAL_ASCII);

DeleteFile (FileName);

Thanks.
0 Kudos
Message 1 of 2
(2,948 Views)
You can't delete an open file. You need to CloseFile() first.

int fpNewFile;
// TO DO: assign a value to the string FileName
fpNewFile = OpenFile (FileName, VAL_READ_WRITE, VAL_OPEN_AS_IS,VAL_ASCII);
// TO DO: write data to file
CloseFile (fpNewFile);
// TO DO: do something with the file
DeleteFile (FileName);
Message 2 of 2
(2,948 Views)