Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: filedelete iniwritepvt
file=FileOpen(...) FileClose(file) For i=1 to 5 if FileExist(file)==1 then FileDelete(file) NextAlso note that as of Winbatch version 97A, FileDelete does not return a false if the file you are trying to delete does not exist. FileDelete will return a 1 if you try to delete a file that does not exist, therefore, be sure to test the existence of the file with FileExist before the FileDelete.
Do not mix file operations and INI operations. This is not a feature of WinBatch but of Windows. When you use iniWritePvt() to update an INI file, Windows broadcasts a message to everybody so that processes that have read the INI file know that the file needs to be re-read. Overwriting an INI file with File operations doesn't result in this broadcast. As a result, nobody, including WinBatch, will know that the file is changed, and everybody, including WinBatch, will use its buffered copy to continue processing.
If you use the IniWrite or IniWritePvt functions to update an INI file, Windows will take its own sweet time to update the copy of the file on disk. There is a trick to tell Windows to update the copy now.
The following is a workaround to force a disk update of an INI file:
IniWritePvt("","","","INIFILE.INI") TimeDelay(1) FileDelete("INIFILE.INI")
Here's my code:
fi=fileitemize("c:\Temp\*.bak") count=Itemcount(fi,@TAB) For x=1 to count file=Itemextract(x,fi,@Tab) test=Filedelete(file) If test==1 Display(1,file,"Sucessfully deleted") Else Message("Problem","%file% not deleted") endif Next Message("Files deleted","Number of files = %Count%")
Dirchange("C:\Temp") ;IMPORTANT to make sure files are deleted from this dir For x=1 to count file=Itemextract(x,fi,@Tab) ...
Article ID: W13066
Filename: FileDelete Returns True but File Shows up in Explorer.txt
File Created: 1999:04:15:16:51:32
Last Updated: 1999:04:15:16:51:32