473,473 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to check to see if a file exist.

How can i check to see if a link (file) exist while a web page is loading.
If the page doesn't exist - i want the hyperlink to go an error page telling
the user the link doesn't exist otherwise they will just go the link which
is a pdf file.

I'm using asp.net 2003.

thanks

Dave
Nov 18 '05 #1
3 4855
have a look at the customerror attributes in the webconfig file

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Dave" <Da**********@hotmail.com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
How can i check to see if a link (file) exist while a web page is loading.
If the page doesn't exist - i want the hyperlink to go an error page
telling
the user the link doesn't exist otherwise they will just go the link which
is a pdf file.

I'm using asp.net 2003.

thanks

Dave

Nov 18 '05 #2
Hi Dave:

Is this a local file on the server? If so, you could use File.Exists
to check (from the System.IO namespace). Don't forget to use
Server.MapPath to get a physical path to the file.

HTH,

--
Scott
http://www.OdeToCode.com

On Tue, 18 May 2004 08:28:26 -0700, "Dave" <Da**********@hotmail.com>
wrote:
How can i check to see if a link (file) exist while a web page is loading.
If the page doesn't exist - i want the hyperlink to go an error page telling
the user the link doesn't exist otherwise they will just go the link which
is a pdf file.

I'm using asp.net 2003.

thanks

Dave


Nov 18 '05 #3
Got it and it works

thanks for help
"Dave" <Da**********@hotmail.com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
How can i check to see if a link (file) exist while a web page is loading.
If the page doesn't exist - i want the hyperlink to go an error page telling the user the link doesn't exist otherwise they will just go the link which
is a pdf file.

I'm using asp.net 2003.

thanks

Dave

Nov 18 '05 #4

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

Similar topics

2
by: JD | last post by:
What im trying to do is something like this maybe in my profile.php file //site thumbnail check//////////// $filename = "sitethumbs/".$user.".jpg"; if (file_exists($filename)) { } else {...
2
by: Lin Ma | last post by:
Greetings, Is it possbile to check a file exist without using Server.CreateObject("Scripting.FileSystemObject") in asp page?? The reason is our hosting company turn that function off for...
3
by: newcomer | last post by:
Is there a way to check if a file exists in Javascript? This is what I'm trying to do: if(thisfile.htm exists) do this else do that
3
by: Matt | last post by:
<input type="file" size=50"> will produce the browse button and browse text box. The user can either select the file from browse button, or enter a path in browse text box manually. My question...
7
by: andylcx | last post by:
Hi all: The c++ language can check whether the file exist or not. I am wondering how c language does this job? Thanks a lot! Andy
4
by: cfyam | last post by:
How can I check some file is exist or not in my evc dll?
6
by: dave | last post by:
Hello All - Is there a way to check if a file path string is valid? I.e. is there a function that takes some string, say 'c:\somedir\subdir' and returns TRUE if it is valid or FALSE if no such...
1
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. It is greatly appreciated. Is there a way to programmatically check for .NET Framework versions installed on the computer? -- Michael Bragg,...
14
by: John Salerno | last post by:
What is the best way to check if a file already exists in the current directory? I saw os.path.isfile(), but I'm not sure if that does more than what I need. I just want to check if a file of a...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.