Hi RaGR,
Not sure why you feel the need to be insulting. I am not a beginner - I have been programming professionally for 17 years, which is why this is not in the beginner's forum. What I do not understand is that this:
works, while this:
...doesn't.
I am well aware that it could be something I have done wrong, but the deletefile above does not delete the INI file even though FileType returns 1, whereas pasting contents of Path$+"Game.ini" into VB KILL command does.
[edit]
I have just hard coded the path and filename:
and the file was not deleted. I have tested this repeatedly in debug mode and FileT% is definitely being set to 1 via FileType when BackDrop%<>0 and LoadFile$="<NONE>" [and "C:\BlitzBasic\SmallSoft\Game.ini" exists!].
Creating a new program with the code:
DID delete the file.
If you can shed any light on what I am doing wrong I would be very grateful.
Not sure why you feel the need to be insulting. I am not a beginner - I have been programming professionally for 17 years, which is why this is not in the beginner's forum. What I do not understand is that this:
Path$=CurrentDir$() FileName$="Test.txt" If FileType(Path$+FileName$)=1 Then DeleteFile Path$+FileName$ EndIf
works, while this:
Graphics ScreenW%,ScreenH%,32,ScreenM% Path$=CurrentDir$() . . . Function BackDropSelect() Local LoadFile$ Local FileT%=0 BackDropDraw() Flip LoadFile$=FileSelect$() If LoadFile$<>"<CANCEL>" Then If LoadFile$="<NONE>" Then If BackDrop%<>0 Then FreeImage BackDrop% BackDrop%=0 FileT%=FileType(Path$+"Game.ini") If FileT%=1 Then DeleteFile Path$+"Game.ini" EndIf ElseIf LoadFile$<>"" BackDropLoad(Path$+LoadFile$) INISave(LoadFile$) EndIf EndIf EndIf BackDropDraw() MenuDraw() End Function
...doesn't.
I am well aware that it could be something I have done wrong, but the deletefile above does not delete the INI file even though FileType returns 1, whereas pasting contents of Path$+"Game.ini" into VB KILL command does.
[edit]
I have just hard coded the path and filename:
Function BackDropSelect() Local LoadFile$ Local FileT%=0 BackDropDraw() Flip LoadFile$=FileSelect$() If LoadFile$<>"<CANCEL>" Then If LoadFile$="<NONE>" Then If BackDrop%<>0 Then FreeImage BackDrop% BackDrop%=0 FileT%=FileType("C:\BlitzBasic\SmallSoft\Game.ini") If FileT%=1 Then DeleteFile "C:\BlitzBasic\SmallSoft\Game.ini" EndIf ElseIf LoadFile$<>"" BackDropLoad(Path$+LoadFile$) INISave(LoadFile$) EndIf EndIf EndIf BackDropDraw() MenuDraw() End Function
and the file was not deleted. I have tested this repeatedly in debug mode and FileT% is definitely being set to 1 via FileType when BackDrop%<>0 and LoadFile$="<NONE>" [and "C:\BlitzBasic\SmallSoft\Game.ini" exists!].
Creating a new program with the code:
FileT%=FileType("C:\BlitzBasic\SmallSoft\Game.ini") If FileT%=1 Then DeleteFile "C:\BlitzBasic\SmallSoft\Game.ini" EndIf
DID delete the file.
If you can shed any light on what I am doing wrong I would be very grateful.