Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileNotFoundException on a mapped drive

Status
Not open for further replies.

thelordoftherings

Programmer
May 16, 2004
616
IL
Hello,

When I use this code on a local drive:
Document document = builder.parse(new File("c:\\test.xml"));
It is working fine but when I do it on a drive e which, is mapped to my pc and contains the same file, like this:
Document document = builder.parse(new File("e:\\test.xml"));
I receive FileNotFoundException. The file is present at the mapped drive. So Why is that?
 
I would have to guess that the file then, does not exist - I can do a similar thing successfully on a mount to a windows server, and a mount to a linxu server via samba - and it finds the file both times ...

--------------------------------------------------
Free Database Connection Pooling Software
 
... lol. Surely our Sauron will have checked that?
 
The file is there and with one "\" it will not work since the File constructor doesn't receive this notation.
 
timw means "/" - the "\" char is the escape character.

--------------------------------------------------
Free Database Connection Pooling Software
 
I am using Windows "/" won't work...

yes it will ... ever tried compiling a file path with a backslash in Visual C++ ? Doesn't work ... the backslash is an escape character ... and in any Java or C or C++ app, a forward slash will always work. I can assure you of that !

--------------------------------------------------
Free Database Connection Pooling Software
 
Well, I tried it, doest work, I receive this error:
The system cannot find the path specified
 
Well, I've just done some java (on win2000) which creates an image file on my mapped W: drive.
Code:
File imageFile = new File("W:/gateway/templates/out.bmp");
ImageIO.write(newImg, "bmp", imageFile);

This worked absolutely fine.
 
My application is being deployed to an Application Server and searches the path there. The path exists on the server but does this fact makes any difference?
 
Does the mapped drive exist on the server?
 
I may assume that the account that launched your AS doesn't see that directory. If you're on Windows, most probably it was launched from SYSTEM account that doesn't have any mapping and in most cases knows nothing about network at all.

Regards, Dima
 
Well, I agree with you, the problem is at the Server.
I tried to create a Virtual Directory on this Server's IIS to the directory where this file exists and even though I set the correct path it couldn't find the file either! If windows couldn't find it, I don't expect Java to find it as well...
So, what should I change on the server in order for this won't happen?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top