| Welcome to WebmasterWorld Guest from 184.108.40.206 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe to WebmasterWorld|
|why is mapPath necessary?|
| 8:58 pm on Mar 14, 2006 (gmt 0)|
why will this work:
Filepath = Server.MapPath("readme.txt");
but not this:
| 1:44 pm on Mar 15, 2006 (gmt 0)|
Because the FileExists() method needs to know the location of the file you'd like to determine existance on.
| 5:39 pm on Mar 15, 2006 (gmt 0)|
Isn't that what paths are for:
is a location
is file in the current directory. Unles asp doesn't like relative paths... I don't get it.
| 5:46 pm on Mar 15, 2006 (gmt 0)|
Like EasyCoder stated, fs.FileExists needs a full path for which to find the file. ie
fs.FileExists("readme.txt") will not work,
fs.FileExists("../yourdir/readme.txt") will not work,
But this will. C:\inetpub\wwwroot\yourdir\readme.txt")
So when you use Sever.MapPath you are literally using the easy way to providing a full path to fs.FileExists.
Use this to get the full path as the server sees it:
| 12:54 am on Mar 16, 2006 (gmt 0)|
Keep in mind that the File System Object is executing somewhere from the System32 or another system folder, not your website folder. So the FileExists method needs to take that into account.
If the method worked the way you've asked here's what would happen... (psuedo code)
public bool FileExists(string in_relativeFileName)
// determine if in_relativeFileName lives in system32
return (bool) if exists relativeFileName in system32? true : false;
public bool FileExists(string in_absoluteFileName)
// determine if in_absoluteFileName lives specified location
return (bool) if exists absoluteFileName in specified location? true : false;
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2013 all rights reserved