System cannot find file even when it exists

5,195

Solution 1

You can create a file like that for testing by typing the following, then hold the ALT and type 255 on the numeric keypad, then release ALT and press ENTER. This will create a filename with a hidden character at the end.

echo.>when_it_initializes.cs

However, the error message I get is:

more when_it_initializes.cs
Cannot access file c:\path\to\file\when_it_initializes.cs

I can delete it with:

del when*

Solution 2

The problem is the total path and file character length. If I run 'rename' through the command prompt I get:

The filename or extension is too long.

But if I then rename the file through explorer to something like "when.cs", then go back to command prompt and run 'notepad' or 'more' or even 'rename' it will work.

It looks like the total file length including directory is between 250-260.

Share:
5,195

Related videos on Youtube

danlash
Author by

danlash

I am Dan lash.

Updated on September 17, 2022

Comments

  • danlash
    danlash almost 2 years

    I have a file that my OS (Windows 2008 Server) / File System (NTFS) are having trouble with. Here is a 'dir' of the directory:

    07/20/2009  11:28 AM    <DIR>          .
    07/20/2009  11:28 AM    <DIR>          ..
    07/20/2009  11:28 AM             9,425 when_it_initializes.cs
                   1 File(s)          9,425 bytes
                   2 Dir(s)  15,536,758,784 bytes free
    

    I am running a command prompt 'as administrator' and using the 'more' command produces:

    more when_it_initializes.cs
    Invalid parameter - when_it_initializes.cs
    

    Similarly when I run 'notepad' on the file I get

    The system cannot find the path specified.
    

    The file was created by Team City, a continuous integration server that builds my code. What is weird is that it also creates over 10k other files that I have no problems opening, even when they are in sibling folders.

    A check of the owner and readonly porperties look ok to me, as compared to other files that work. What is weird is that if I use 'explorer' to launch 'notepad' and open the, it works fine. I'm thinking there might be something with the command prompt that is affecting it, but I don't know.

    What else can I check to see why it cannot open?

    • Rowland Shaw
      Rowland Shaw almost 15 years
      You might get more answers on superuser.com
    • Spence
      Spence almost 15 years
      Assuming you have <TAB> filename completion turned on in CMD, I'm wondering what happens if you go into that directory and enter your "more" command, a space, and hit <TAB> to get the filename before pressing <ENTER>. It sounds to me like something is up w/ the filename and possibly trailing non-visible characters.
    • Ernie
      Ernie almost 15 years
      @Evan: Wouldn't that be handled by Notepad when you access the file through explorer?
    • danlash
      danlash almost 15 years
      @Evan <TAB> completetion does work in command prompt @Ernie I agree
  • danlash
    danlash almost 15 years
    The type of the file system is NTFS. D: is not dirty.
  • Saurabh Barjatiya
    Saurabh Barjatiya almost 15 years
    It is weird that OS so recent as Server 2008 is not supporting path greater than 256 characters.