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 3584
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |