Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 24th, 2004, 04:07 AM
Authorized User
 
Join Date: Jun 2004
Location: , , India.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to silver_cuts Send a message via Yahoo to silver_cuts
Default filename validation

Hi all

If i have just the filename of a file and not the complete path is there any way that i can validate whether it is a valid file or not...

i am writing an application in ASP and using VBScript for writing my scripts ...

Thanks in advance..

Sudhan
__________________
--------------------------------------------------
Sudhan Kanitkar.
Everything Is In Our Hands.
Reply With Quote
  #2 (permalink)  
Old June 24th, 2004, 04:11 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Without knowing the files path I think you would have to do a recursive function to go through all the files on the system to find its path.

Then you can test with the file system objects fileExists() function.

But this would be very heavy on a server if done as a matter of course, I would not recommend this.

How come you don't know the path?

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #3 (permalink)  
Old June 24th, 2004, 04:21 AM
Authorized User
 
Join Date: Jun 2004
Location: , , India.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to silver_cuts Send a message via Yahoo to silver_cuts
Default

Hi Rod,

What is the method if i know the path ? I can change a bit to get the complete path ...

Sudhan.

Reply With Quote
  #4 (permalink)  
Old June 24th, 2004, 04:25 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

IF you know the path it is the fileExists() function of the FileSystemObject.
Just wait one minute I'll give you some code snippet.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #5 (permalink)  
Old June 24th, 2004, 04:28 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

dim fso
set fso = CreateObject("Scripting.FileSystemObject")
File = "C:\\AFileOnYourServer.txt"
if fso.fileExists(XLFile) then

end if

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #6 (permalink)  
Old June 24th, 2004, 04:30 AM
Friend of Wrox
Points: 2,376, Level: 20
Points: 2,376, Level: 20 Points: 2,376, Level: 20 Points: 2,376, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , Australia.
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Silver_cuts,

Here is a code snippet

Code:
dim fso
set fso = CreateObject("Scripting.FileSystemObject")

'Change name here to point to a file
theFile = "C:\\AFileOnYourServer.txt"

if fso.fileExists(theFile) then
'Do Your Stuff
Response.write("Yes the file exists")
else
Response.write("The file does not exist")

end if


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply With Quote
  #7 (permalink)  
Old June 24th, 2004, 06:24 AM
Authorized User
 
Join Date: Jun 2004
Location: , , India.
Posts: 68
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to silver_cuts Send a message via Yahoo to silver_cuts
Default

Hi Rod,

It works great ... i am able to use it just as i needed ... will write more if i get into trouble ..

Sudhan

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
filename validation mayuraprabhu Pro VB 6 1 December 15th, 2006 02:43 PM
Renaming filename simone_s Java Basics 2 May 18th, 2006 12:17 PM
Dynamic Filename ozPATT Access VBA 1 November 28th, 2005 01:56 PM
Invalid filename Bhavin Crystal Reports 0 December 15th, 2004 05:00 PM



All times are GMT -4. The time now is 05:33 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.