PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 19, 2022

[FIXED] how can I delete file which has invalid file name?

 October 19, 2022     admin, delete-file, filenames, windows     No comments   

Issue

enter image description here

There is 2 loader.bin. But one of them has carrage return at the end of the file name. Because of this, I can't delete the file, and directory containing the file. Even with command prompt, I can't delete it. I tried:

del *
del loader.*

above says name or label is wrong. So I

cd ..
dir /x

to check DOS path name of the directory And delete with DOS path del TEXT_L~1 and again, above says name or label is wrong.

I also tried to delete the directory with "\?\" prefix. something like:

del "\\?\D:\directory\blahblah\directory"

and again, name error occurs.

How can I delete this file? Can I have some hint?

I guess that there is carriage return at the end of name because auto complete in git bash complete the name as "loader.bin^M"

I think the file came from wrong command from batch file like:

fasm file.asm loader.bin(here's carriage return)

(fasm is assembler program) Batch file's end of line may have been changed while I changed platform from linux to windows.

EDIT: The file refused to get deleted with following method too.

  1. delete with /P option

    del /P directoryName
    
  2. with DeleteFileW windows API

    #include <windows.h>
    int main()
    {
        DeleteFileW(L"E:\\directory\\blahblah\\directory");
    }
    

Solution

this problem never happened to me but maybe using del /P directory you could be able to remove the file.

Example

Update

You could use a live Linux distro and delete the file you need.

Thanks



Answered By - Alberto
Answer Checked By - David Goodson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing