Print Page | Close Window

FileSystemObject - check if folder exsits

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=5428
Printed Date: 30 March 2026 at 11:00pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: FileSystemObject - check if folder exsits
Posted By: Scotty32
Subject: FileSystemObject - check if folder exsits
Date Posted: 01 September 2003 at 3:01pm

how do i stop the error if a folder doesnt exicist?

or better, how do i do an "if ... then ... else... end if" statement

so i can say "sorry this folder doesnt exicist... click here to create it"




Replies:
Posted By: MorningZ
Date Posted: 02 September 2003 at 6:43am

while i typically hate using On..Error..Resume..Next, it does serve purpose sometimes

<%
Dim objFSO, objFolder
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
On error resume next
Set objFolder = objFSO.GetFolder("/upload/folder01/")
if err.number > 0 then
   Response.Write("Folder doesn't exist, would you like to create it?")
else
   Response.Write("Folder exists.. do whatever here")
end if
on error goto 0
Set objFSO = Nothing
%>



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: pmormr
Date Posted: 02 September 2003 at 4:50pm

there's a filesystemobject method to check to see if a folder exists.

if NOT objFSO.folderexists("c:\myfolder") then
Response.write("Folder Doesn't exist")
End if



-------------
Paul A Morgan

http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/


Posted By: Scotty32
Date Posted: 03 September 2003 at 2:45am

thanks, ive tried MorningZ and got that to work

i have seen to check if a file excisted but didnt know if there was one to check a folder

i'll give pmormr's a try, thanks for the help




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net