I need to determine if a file exists using code.
I tried using the system.io.file.exists function, that will appears to
locate the file if I use the complete filespec, when I move the project to
the web server, that command will not work because I can not specify the
entire path, just the path relative to the default project folder.
Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
If I use the above system.io.file.exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\My
Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg"
If I use the above system.io.file.exists succeeds.
You see how the second example would not work on an ISPs server.
any suggestions.
thanks
steve 7 3702
Server.MapPath
"Stephen E. Weber" <sw@webersystems.com> wrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl... I need to determine if a file exists using code.
I tried using the system.io.file.exists function, that will appears to locate the file if I use the complete filespec, when I move the project to the web server, that command will not work because I can not specify the entire path, just the path relative to the default project folder.
Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
If I use the above system.io.file.exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\My Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg"
If I use the above system.io.file.exists succeeds.
You see how the second example would not work on an ISPs server.
any suggestions. thanks steve
"Stephen E. Weber" <sw@webersystems.com> wrote in message
news:eQ**************@TK2MSFTNGP03.phx.gbl... Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
That's a Unix path definition. It means [HOME]/image/NoImageAvailable.jpg
Thanks for the advise and information!
ok, that makes sense, I assume in Windows land I can use the ".." for
current folder, do you know if there is a specification for home folder in
windows land?
thanks
Steve
"Homer J Simpson" <no****@nowhere.com> wrote in message
news:c%j%f.72479$%H.41820@clgrps13... "Stephen E. Weber" <sw@webersystems.com> wrote in message news:eQ**************@TK2MSFTNGP03.phx.gbl...
Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
That's a Unix path definition. It means [HOME]/image/NoImageAvailable.jpg
Thanks for the tip, but in this case i dont think its gonna apply, I know
what the entire path of the file from the root is, which is what this
command appears to return, I need a way to specify the path from the home
folder on the web site, on most servers I dont have access to the full root
and they differ, Im trying to use a path that will work on any server.
thanks
"Jeff Dillon" <je********@hotmail.com> wrote in message
news:ul*************@TK2MSFTNGP04.phx.gbl... Server.MapPath
"Stephen E. Weber" <sw@webersystems.com> wrote in message news:eQ**************@TK2MSFTNGP03.phx.gbl...I need to determine if a file exists using code.
I tried using the system.io.file.exists function, that will appears to locate the file if I use the complete filespec, when I move the project to the web server, that command will not work because I can not specify the entire path, just the path relative to the default project folder.
Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
If I use the above system.io.file.exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\My Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg"
If I use the above system.io.file.exists succeeds.
You see how the second example would not work on an ISPs server.
any suggestions. thanks steve
"Stephen E. Weber" <sw@webersystems.com> wrote in message
news:OT**************@TK2MSFTNGP02.phx.gbl... Thanks for the advise and information!
ok, that makes sense, I assume in Windows land I can use the ".." for current folder, do you know if there is a specification for home folder in windows land?
Actually . is the current folder, .. is the parent (just like Unix -- which
Gates copied from)
"Special' folders, like My Documents, do have specific .Net names. I've seen
that question answered here before. However there is no real 'Home' folder
in Dos/Windows etc.
See "My.Computer.FileSystem.SpecialDirectories Object Members" and
"My.Computer.FileSystem.SpecialDirectories Property" for the paths etc.
/include/somepath/filename
will always be from the root of the virtual directory
like
c:\inetpub\wwwroot\vdir\include\sompath
Jeff
"Homer J Simpson" <no****@nowhere.com> wrote in message
news:c%j%f.72479$%H.41820@clgrps13... "Stephen E. Weber" <sw@webersystems.com> wrote in message news:eQ**************@TK2MSFTNGP03.phx.gbl...
Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
That's a Unix path definition. It means [HOME]/image/NoImageAvailable.jpg
That doesn't make any sense. Either server.mappath will give you the fully
qualified path, or simply a relative path from the root will always work too
File.IO needs the fully qualified path.
Jeff
"Stephen E. Weber" <sw@webersystems.com> wrote in message
news:uV*************@TK2MSFTNGP05.phx.gbl... Thanks for the tip, but in this case i dont think its gonna apply, I know what the entire path of the file from the root is, which is what this command appears to return, I need a way to specify the path from the home folder on the web site, on most servers I dont have access to the full root and they differ, Im trying to use a path that will work on any server.
thanks
"Jeff Dillon" <je********@hotmail.com> wrote in message news:ul*************@TK2MSFTNGP04.phx.gbl... Server.MapPath
"Stephen E. Weber" <sw@webersystems.com> wrote in message news:eQ**************@TK2MSFTNGP03.phx.gbl...I need to determine if a file exists using code.
I tried using the system.io.file.exists function, that will appears to locate the file if I use the complete filespec, when I move the project to the web server, that command will not work because I can not specify the entire path, just the path relative to the default project folder.
Example
This is the path my image property uses: "~/image/NoImageAvailable.jpg"
If I use the above system.io.file.exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\My Documents\Visual Studio 2005\WebSites\GshockWatch\NoImageAvailable.jpg"
If I use the above system.io.file.exists succeeds.
You see how the second example would not work on an ISPs server.
any suggestions. thanks steve
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kamus of Kadizhar |
last post by:
Thanks to everyone on this list. I now have a functioning piece of
python code!! :-))
Now I'm trying to clean it up.
I have the same (or similar) lines repeated several times:
...
|
by: OvErboRed |
last post by:
Hi, I'm trying to determine whether a given URL exists. I'm new to Python
but I think that urllib is the tool for the job. However, if I give it a
non-existent file, it simply returns the 404 page....
|
by: Opie |
last post by:
What would be a more efficient way for me to determine if a record in an SQL
DB table exists? Right now, I have a try/catch like this:
try
{...
|
by: Darrell Wesley |
last post by:
Is there any better method of determining if a file exists then using the Scripting.FileSystemObject
If I do thi
Dim fs As New System.IO.StreamReader(FileName
and the file does not exist...
|
by: Wayne Wengert |
last post by:
I am trying to determine if a file exists on a web site but I cannot get a
match. I have verified that the file does exists in the specified directory
(I verified the case of the file and directory...
|
by: Tim Daneliuk |
last post by:
I have a program wherein I want one behavior when a file is set as executable
and a different behavior if it is not. Is there a simple way to determine
whether a given named file is executable...
|
by: topramen |
last post by:
does any one here know of a good way to to determine whether or not a
given path is a directory (e.g., "c:\mydir") or a file (e.g., "c:\mydir
\myfile.txt")?
i started attacking this problem by...
|
by: Cramer |
last post by:
I'm wondering if there is an easy way to programmatically determine if an
assembly is installed in the GAC.
This would be similar to our ability to easily determine if a file exists...
|
by: LordHog |
last post by:
Hello,
How would I go about finding the default handler, let's say a text
file (*.txt), then launch the default handler with the file as an
argument? I had found how to launch an external...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |