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/NoImageAvailabl e.jpg"
If I use the above system.io.file. exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\ My
Documents\Visua l Studio 2005\WebSites\G shockWatch\NoIm ageAvailable.jp g"
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 3715
Server.MapPath
"Stephen E. Weber" <sw@webersystem s.com> wrote in message
news:eQ******** ******@TK2MSFTN GP03.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/NoImageAvailabl e.jpg"
If I use the above system.io.file. exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\ My Documents\Visua l Studio 2005\WebSites\G shockWatch\NoIm ageAvailable.jp g"
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@webersystem s.com> wrote in message
news:eQ******** ******@TK2MSFTN GP03.phx.gbl... Example
This is the path my image property uses: "~/image/NoImageAvailabl e.jpg"
That's a Unix path definition. It means [HOME]/image/NoImageAvailabl e.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.7247 9$%H.41820@clgr ps13... "Stephen E. Weber" <sw@webersystem s.com> wrote in message news:eQ******** ******@TK2MSFTN GP03.phx.gbl...
Example
This is the path my image property uses: "~/image/NoImageAvailabl e.jpg"
That's a Unix path definition. It means [HOME]/image/NoImageAvailabl e.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********@hot mail.com> wrote in message
news:ul******** *****@TK2MSFTNG P04.phx.gbl... Server.MapPath
"Stephen E. Weber" <sw@webersystem s.com> wrote in message news:eQ******** ******@TK2MSFTN GP03.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/NoImageAvailabl e.jpg"
If I use the above system.io.file. exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\ My Documents\Visua l Studio 2005\WebSites\G shockWatch\NoIm ageAvailable.jp g"
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@webersystem s.com> wrote in message
news:OT******** ******@TK2MSFTN GP02.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.Fi leSystem.Specia lDirectories Object Members" and
"My.Computer.Fi leSystem.Specia lDirectories Property" for the paths etc.
/include/somepath/filename
will always be from the root of the virtual directory
like
c:\inetpub\wwwr oot\vdir\includ e\sompath
Jeff
"Homer J Simpson" <no****@nowhere .com> wrote in message
news:c%j%f.7247 9$%H.41820@clgr ps13... "Stephen E. Weber" <sw@webersystem s.com> wrote in message news:eQ******** ******@TK2MSFTN GP03.phx.gbl...
Example
This is the path my image property uses: "~/image/NoImageAvailabl e.jpg"
That's a Unix path definition. It means [HOME]/image/NoImageAvailabl e.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@webersystem s.com> wrote in message
news:uV******** *****@TK2MSFTNG P05.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********@hot mail.com> wrote in message news:ul******** *****@TK2MSFTNG P04.phx.gbl... Server.MapPath
"Stephen E. Weber" <sw@webersystem s.com> wrote in message news:eQ******** ******@TK2MSFTN GP03.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/NoImageAvailabl e.jpg"
If I use the above system.io.file. exists fails
if I use the full filespec: " E:\Documents and Settings\Steve\ My Documents\Visua l Studio 2005\WebSites\G shockWatch\NoIm ageAvailable.jp g"
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:
shutil.copy2(newArrivalsDir+'/'+movie,archivesDir)
thumb = string.replace(movie,'.avi','.jpg')
shutil.copy2(newArrivalsDir+'/tn/'+thumb,archivesDir+'/tn/')
|
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. Aside from grepping this
for '404', is there a better way to do this? (Preferrably, there is a
solution that can be applied to both HTTP and FTP.)...
|
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
{
if(checkcom.ExecuteScalar().ToString()==tbBillNumber.Text)
{
....
}
}
|
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 thena n exception is thrown, how can you determine if the file exists before attemptng to open it
|
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 name). The code (below) is
from one of my aspx pages. Is there something here I overlooked?
Wayne
======================= code ...
| |
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 that does not resort to all the
lowlevel ugliness of os.stat() AND that is portable across Win32 and *nix?
Thanks,...
|
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 using filesystemobject to check
whether or not a directory existed for the path. if so, it was a
directory path. if not, i checked to see if a file...
|
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
(File.Exists(path)) - but for an assembly, of a particular version, etc in
the GAC.
I have googled this and failed to find anything useful.
Thanks
|
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 program, but I do not
know how I would find the default handler to a file type. Any help is
greatly appreciated.
Code to launch application:...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |