0

I cannot delete a jpg, png or bmp using Windows DeleteFile or remove. I can, however, delete other types of files in the same directory (txt, yaml). To make things even weirder, I can open a command prompt and remove the file using the "rm" command (I'm not opening the terminal window as an admin). I've even tried creating a new bitmap and saving it to ensure it wasn't some encryption I was missing however I still cannot delete it.
I am running Windows 11 and Visual Studio 2019 and yes, I am the owner of and do have full permissions on the file and no, the file is not opened first.

    int retVal = ::remove("C:\\Users\\melis\\Projects\\BartonNoProp.jpg");  //THIS FAILS
    retVal = ::remove("C:\\Users\\melis\\Projects\\Barton.jpg");  //THIS FAILS
    retVal = ::remove("C:\\Users\\melis\\Projects\\ss.yaml");  //THIS IS SUCCESSFUL

    BOOL result = ::MoveFileEx("C:\\Users\\melis\\Projects\\Barton.jpg", "C:\\Users\\melis\\Projects\\Train\\Barton.jpg", MOVEFILE_REPLACE_EXISTING);
    int rr = ::GetLastError();  //THIS SUCCEEDS IF THE SECOND FILE DOESN'T EXIST.  HOWEVER, IT FAILS IF THE SECOND FILE ALREADY EXISTS.

    result = ::DeleteFile("C:\\Users\\melis\\Projects\\ss2.yaml");
    rr = ::GetLastError();  // THIS IS SUCCESSFUL

    result = ::DeleteFile("C:\\Users\\melis\\Projects\\BartonNoProp.jpg");
    rr = ::GetLastError();  // THIS FAILS WITH CODE 5
MelissaS
  • 1
  • 1
  • do you have any antivirus software where you have not excluded the directory? maybe that is interfering? – AndersK Jul 27 '23 at 18:04
  • 1
    YES. That was IT. I can't believe I overlooked that. My computer came with a free trial of Norton and sure enough "Data Protection" was checked and included all image formats. Thank you!! – MelissaS Jul 27 '23 at 19:51

0 Answers0