dror700
asked on
to delete file with visual studio c
hi, i need code that delete binary files in visual c
thanks....
thanks....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or you can just use system("del C:\\folder\\file.txt"); (Or on *NIX, "rm /home/folder/file.txt")
That will work regardless of your build environment.
That will work regardless of your build environment.
There is also the run time library function remove that goes back to pre Windows days
int remove ( const char * path)
int _wremove ( const wchar_t * path)
Function returns 0 if successful and -1 if not. If -1 then errno is set to EACSS (file read only or is open) ENOENT to indicate path not found.
This is for information only - if possible I would go with jaime_olivares recommendation.
int remove ( const char * path)
int _wremove ( const wchar_t * path)
Function returns 0 if successful and -1 if not. If -1 then errno is set to EACSS (file read only or is open) ENOENT to indicate path not found.
This is for information only - if possible I would go with jaime_olivares recommendation.
Oh just a comment on system - it will work but your return values are not as significant as for DeleteFile and remove - with the latter you can get more information about why a delete failed.
Again for info purposes and not an attempt to lessen ch0c's suggestion which is still valid.
Again for info purposes and not an attempt to lessen ch0c's suggestion which is still valid.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/deletefile.asp