Don't be helpless: What might be the reason for a "Path not found" error?

Raymond Chen

Internally at Microsoft, we have a programmer’s tool which I will call Program Q. On the peer-to-peer mailing list for Program Q, somebody asked the following question:

When I try to do a q edit template template_name, instead of opening an editor window where I can modify the template, I get the following error:

Error opening for write:
C:\Users\Waldo\AppData\Local\Temp\2\t144t4.tmp
The system cannot find the path specified.

Can you help resolve this error?

Okay, there is already everything you need in the error message. The program even converted the error number to error text for you. You just have to read it and think about what it’s telling you.

The file is C:\Users\Waldo\AppData\Local\Temp\2\t144t4.tmp. Therefore the path is C:\Users\Waldo\AppData\Local\Temp\2. I leave you to determine the next step in the investigation.

That was apparently not enough of a nudge in the right direction.

While the error message does say “The system cannot find the path specified,” the fact remains that I did not specify a path at all. The path in the error message is completely unknown to me. I could try to navigate to that path in Windows Explorer, but I doubt that this has anything to do with resolving the problem.

Normally, I get an editor window that lets me edit the template, but instead I get this strange error message which I’ve never seen before.

I did not try to navigate to the path mentioned in the error message simply because the mentioned Temp folder C:\Users\Waldo\AppData\Local\Temp is completely empty!

The helplessness is so thick you can cut it with a knife! I also find it astonishing that the person thinks that verifying whether the path can be found is totally unrelated to resolving a “Path not found” error.

Don’t forget, this is a programmer’s tool. One should assume that the people who use it have some level of technical skill!

Okay, first we have a “Path not found” error, and there is a fully-qualified file name whose path couldn’t be found. First thing to check is whether the path really exists. From the most recent reply, one can see that the answer is “No, it does not exist.” The 2 subdirectory is missing from the Temp directory.

Okay, so we verified that the error message is valid. The next thing to determine is where the program got this path from. The person already recognized that it was the Temp directory, and it shouldn’t be a huge deductive leap to determine that the path probably came from the TEMP or TMP environment variable.

The observation that the Temp directory is completely empty suggests that the person, in an obsessive-compulsive fit, deleted everything from the Temp directory, including the 2 subdirectory. Too bad that their TEMP environment variable still contained a reference to it.

As a result, any program that wants to create a temporary file will try to create it in a directory that doesn’t exist. Result: “Path not found.”

The fix: Re-create the 2 subdirectory that you mistakenly deleted. (And yes, this fixed the problem.)

It somehow seemed completely surprising to this person that a “Path not found” error could possibly mean that a path couldn’t be found.

0 comments

Discussion is closed.

Feedback usabilla icon