472,352 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 software developers and data experts.

Determine if a File exists

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
Apr 12 '06 #1
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


Apr 12 '06 #2

"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

Apr 13 '06 #3
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

Apr 13 '06 #4
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


Apr 13 '06 #5

"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.

Apr 13 '06 #6
/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

Apr 13 '06 #7
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



Apr 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
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...
2
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...
6
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 {...
8
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...
2
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...
28
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...
1
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...
7
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...
3
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...
0
jalbright99669
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...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
2
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...
0
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...
0
hi
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...
0
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...
0
Oralloy
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...
0
BLUEPANDA
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.