Delete File

IS there a way to Delete a file w/ read only attributes.

For some reasonwhen I use the function DeleteFile() it IS NOT deleteing my File. It returns 0. I know the path is correct. Also, if I go undo the read only properties before the Delete is called it deletes the File, otherwise it DOES NOT delete the file.

The problem is all the files I need to Delete will have Read Only properites.

I could not figure out how to do this. Is there a way to set the attributes from the APP. I actually though you can pass a bool value to the DeleteFile() to delete a Read Only file, but I think I am wrong!!

Thanks for all the help guys
[668 byte] By [lyar1031] at [2007-11-18 17:44:48]
# 1 Re: Delete File
Check MSDN for CFile::GetStatus to determine the attributes of a file and then change the attributes using CFile::SetStatus.

Hope this helps

SMA.
sma at 2007-11-11 1:25:51 >
# 2 Re: Delete File
DeleteFile should be deleting read-only files.

You can call GetLastError() to find out why the call to DeleteFile is failing!

You shouldn't need to in this case, but you can modify file attributes many ways, one of which is GetFileAttributes, and SetFileAttributes.
RasKalnikov at 2007-11-11 1:26:56 >