Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base

Post new topic   Reply to topic
Check If Folder Exists
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Aug 24th, 2004 07:28 AM    Post subject: Check If Folder Exists Reply with quote

[vb:1:cf6a2aeaea]Public Function CheckDir(Byval sPath As String) As Boolean
If Dir(sPath, vbDirectory) = "" Then CheckDir = False Else CheckDir = True
End Function[/vb:1:cf6a2aeaea]

Usage:

[vb:1:cf6a2aeaea]GetAns = CheckDir(App.Path & "\SomeDirectory")
Msgbox GetAns[/vb:1:cf6a2aeaea]
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
P.T.A.M.
Administrator


Joined: 08 Oct 2003
Posts: 752
Location: Greece

PostPosted: Aug 24th, 2004 09:19 AM    Post subject: Reply with quote

Simpler "

[vb:1:bdd711827a]Public Function CheckDir(ByVal sPath As String) As Boolean
If Dir(sPath, vbDirectory) <> "" Then CheckDir = True
End Function[/vb:1:bdd711827a]

Since the default value is 0 (False) you don't need to set it Wink
_________________
No one is completely useless. They can at least be an example of what to avoid.
Back to top
View user's profile Send private message Send e-mail Visit poster's website ICQ Number
rbgCODE
Regular


Joined: 11 Nov 2004
Posts: 54
Location: Manchester CT

PostPosted: Nov 15th, 2004 10:29 PM    Post subject: Reply with quote

snap
_________________
'><>
'rBg
'><>
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
vbman995
Moderator


Joined: 19 Aug 2005
Posts: 264
Location: Planet Earth

PostPosted: Sep 14th, 2005 02:04 PM    Post subject: Reply with quote

Hey..... Newbies, this is great code...you can use it to see if a file exists before trying to open it with your program.....
Back to top
View user's profile Send private message
i_am_doofus
Regular


Joined: 04 Jun 2005
Posts: 57

PostPosted: Sep 15th, 2005 07:41 AM    Post subject: Reply with quote

Even easier, add reference to Microsoft Scripting Runtime and use FileSystemObject.FolderExists

Code:

Dim fs As FileSystemObject

    your_boolean_variable= fs.FolderExists("path_to_your_folder")
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Knowledge Base All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic