Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2004, 04:07 AM
Authorized User
 
Join Date: Jun 2004
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.
 
Old June 24th, 2004, 04:11 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
======================================
 
Old June 24th, 2004, 04:21 AM
Authorized User
 
Join Date: Jun 2004
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.

 
Old June 24th, 2004, 04:25 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
======================================
 
Old June 24th, 2004, 04:28 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
======================================
 
Old June 24th, 2004, 04:30 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
======================================
 
Old June 24th, 2004, 06:24 AM
Authorized User
 
Join Date: Jun 2004
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






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





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