When I called DeleteFile() or ZwDeleteFile() with an invalid file name, they both failed with ERROR_INVALID_NAME (again, with ZwDeleteFile(), after using RtlNtStatusToDosError()) and not ERROR_FILE_NOT_FOUND. They all fail with ERROR_INVALID_NAME (in the case of ZwCreateFile(), after using RtlNtStatusToDosError()).Įven if I had a file with an invalid character in its name, I doubt DeleteFile() would be able to delete it. I tried CreateFileA(), CreateFileW(), and even ZwCreateFile() and none of them would let me create a file with an invalid character in its name. I tried a number of times with a variety of different invalid characters including U+0012, which appears to be the invalid character in your file's name. I can't be absolutely sure though, as I have been unable to create a file with an invalid character in its name.
How to delete a zero byte file with an invalid filename windows#
I don't think you can delete a file with an invalid character in its name using the Win32 API, at least not in Windows 2000, which is the operating system under which I ran these tests. So you might as well stop now because it doesn't look like the Win32 API will accept the invalid file name. Playing with the shell and various scripting languages are ultimately just different ways of passing the invalid file name to the Win32 API. (duh View image: /infopop/emoticons/icon_smile.gif )
this should work much better and not require any tracing of the character ASCII code. Msgbox "File Deleted!", vbokonly + vbExclamation, "Success" StrFileName = "c:\program files\network ice\blackice\hosts\" & chr(ICounter) & "44E0D~1.txt" Set fso = CreateObject ("scripting.filesystemobject") Or, you could try vbscript and use the chr function to generate the correct file name. Try using the tab-completion, and then edit the file name and preceed the weird character with a \ or enclose the entire name in back quotes. this is typically a unix thing, but it might work in cmd. Including my attempts to rid myself of the files, and suggestions from others.Īnother thought. Others have said 'you're just not following the instructions', but the files won't budge, and no amount of tweaking helps. I have six files on my disk, and I don't think I'll be able to get rid of them under Windows XP without hex-editing the disk itself. The way I resolved my problem was to get rid of all the files I could from the directory, and then RENAME the directory itself to 'badfiles' and MOVE the directory to the top level of my disk, then I could delete the subdirectories that were 'locked' due to undeletable files. There was another thread on deleting files, and none of the solutions would work on MY problem files, because I got the error message that you're encountering. The files were created in a Eudora directory, and have CTRL-D's embedded in them.