PC Review


Reply
Thread Tools Rate Thread

Directory Exists

 
 
Steven
Guest
Posts: n/a
 
      1st Jun 2009
Is there a way to tell if a directory exists. Not a file in a directory
...... but a directory.


Thank you,

Streven
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      1st Jun 2009
Function FolderExists(strPath As String) As Boolean
On Error Resume Next
FolderExists = ((GetAttr(strPath) And vbDirectory) = vbDirectory)
End Function

Explanation:
http://allenbrowne.com/func-11.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Steven" <(E-Mail Removed)> wrote in message
news:58D56B87-6D35-462A-8222-(E-Mail Removed)...
> Is there a way to tell if a directory exists. Not a file in a directory
> ..... but a directory.
>
>
> Thank you,
>
> Streven

 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      1st Jun 2009
You can use the Dir() function, passing the optional argument as vbDirectory

If Len(Dir("C:\Folder", vbDirectory)) = 0 Then
MsgBox "Folder Doesn't Exist"
End If

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Steven" wrote:

> Is there a way to tell if a directory exists. Not a file in a directory
> ..... but a directory.
>
>
> Thank you,
>
> Streven

 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      1st Jun 2009
Actually that doesn't quite cut it.

If there was a file named "Folder", our example would not give the right
answer, Jack.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Jack Leach" <dymondjack at hot mail dot com> wrote in message
news:76F00ECE-D334-4E72-BC4C-(E-Mail Removed)...
> You can use the Dir() function, passing the optional argument as
> vbDirectory
>
> If Len(Dir("C:\Folder", vbDirectory)) = 0 Then
> MsgBox "Folder Doesn't Exist"
> End If
>
> --
> Jack Leach
> www.tristatemachine.com
>
> "I haven't failed, I've found ten thousand ways that don't work."
> -Thomas Edison (1847-1931)
>
>
>
> "Steven" wrote:
>
>> Is there a way to tell if a directory exists. Not a file in a directory
>> ..... but a directory.
>>
>>
>> Thank you,
>>
>> Streven


 
Reply With Quote
 
Jack Leach
Guest
Posts: n/a
 
      1st Jun 2009
Sorry, you're right. You would have to add the trailing "\" to make Dir
return "."

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)



"Allen Browne" wrote:

> Actually that doesn't quite cut it.
>
> If there was a file named "Folder", our example would not give the right
> answer, Jack.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Jack Leach" <dymondjack at hot mail dot com> wrote in message
> news:76F00ECE-D334-4E72-BC4C-(E-Mail Removed)...
> > You can use the Dir() function, passing the optional argument as
> > vbDirectory
> >
> > If Len(Dir("C:\Folder", vbDirectory)) = 0 Then
> > MsgBox "Folder Doesn't Exist"
> > End If
> >
> > --
> > Jack Leach
> > www.tristatemachine.com
> >
> > "I haven't failed, I've found ten thousand ways that don't work."
> > -Thomas Edison (1847-1931)
> >
> >
> >
> > "Steven" wrote:
> >
> >> Is there a way to tell if a directory exists. Not a file in a directory
> >> ..... but a directory.
> >>
> >>
> >> Thank you,
> >>
> >> Streven

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
UNC Directory Exists quimbo Microsoft Dot NET Framework 3 29th Dec 2009 05:07 PM
How do I check if a directory exists within another directory aine_canby@yahoo.com Microsoft C# .NET 1 8th Nov 2007 10:47 AM
If A Directory Exists =?Utf-8?B?YWNoaWRzZXk=?= Microsoft Excel Programming 2 4th Feb 2006 09:00 PM
Directory.Exists Phil Barber Microsoft C# .NET 1 19th Jan 2006 04:31 PM
Directory.Exists(path) creates a directory =?Utf-8?B?U3RyaWc=?= Microsoft Dot NET Framework 4 5th Sep 2004 06:33 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:13 AM.