# System cannot find file even when it exists

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?

-
You might get more answers on superuser.com –  Rowland Shaw Jul 20 '09 at 16:02
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. –  Evan Anderson Jul 20 '09 at 16:04
@Evan: Wouldn't that be handled by Notepad when you access the file through explorer? –  Ernie Jul 20 '09 at 17:16
@Evan <TAB> completetion does work in command prompt @Ernie I agree –  danlash Jul 20 '09 at 17:28

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*

-

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.

-
It is weird that OS so recent as Server 2008 is not supporting path greater than 256 characters. –  Saurabh Barjatiya Jul 20 '09 at 18:00

It may be a problem with the name of the parent directory (or its parents).

It may be a problem with the disk, run CHKNTFS.

-
The type of the file system is NTFS. D: is not dirty. –  danlash Jul 20 '09 at 17:27
As for the name thing ... the only thing I can think of with that is the 255 upper limit on directory + file. But this combination is only 239 –  danlash Jul 20 '09 at 17:33

It should not be a file-system problem as you can open file from explorer. So the problem should be in name as Dennis suggested. Try shell wildcards like del *.* or type *.* and check the output. If wildcards work then problem is most probably due to use of special ASCII character (or weird Unicode character, if supported - I am not sure about this).

-