PC Review


Reply
Thread Tools Rate Thread

Checking to see of a folder exists

 
 
Chuck M
Guest
Posts: n/a
 
      28th Feb 2008
Hi,

I'm using a DIR command to verify that a folder exists on a local C: drive.
If I need to check a folder on a network drive, can I use the mapped drive
letter or must I supply a UNC path to the DIR command. I don't have the
resources to test this myself.

TIA
--
Chuck M.
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      28th Feb 2008
I've used this before, but it's untested, uncompiled here.

Dim TestStr as string
teststr = ""
on error resume next
teststr = dir("\\your\unc\path\here" & "\nul")
on error goto 0

if teststr = "" then
'not there
else
'is there
end if



Chuck M wrote:
>
> Hi,
>
> I'm using a DIR command to verify that a folder exists on a local C: drive.
> If I need to check a folder on a network drive, can I use the mapped drive
> letter or must I supply a UNC path to the DIR command. I don't have the
> resources to test this myself.
>
> TIA
> --
> Chuck M.


--

Dave Peterson
 
Reply With Quote
 
ward376
Guest
Posts: n/a
 
      28th Feb 2008
You should use the path with the server name if distributing to other
users. If you're the only one using it, and you don't change your
drive letters, using the drive letter in the path is fine.

Cliff Edwards
 
Reply With Quote
 
Chuck M
Guest
Posts: n/a
 
      28th Feb 2008
Thank you. The particular drive in question is mapped the same for all users.
--
Thanks.
Chuck M.


"ward376" wrote:

> You should use the path with the server name if distributing to other
> users. If you're the only one using it, and you don't change your
> drive letters, using the drive letter in the path is fine.
>
> Cliff Edwards
>

 
Reply With Quote
 
Stefi
Guest
Posts: n/a
 
      3rd Jun 2008
Hi Dave,

I was looking for a solution for checking the existence of a server and
found this post of yours and hoped it helps me, but it doesn't. It returns a
wrong False value if path to be checked consists of only the server name.

My aim is to separate cases of non-existence of a folder:

1. The folder doesn't exist on an existing server.
2. The folder doesn't exist because the server itself doesn't exist (e.g.
its name is mis-spelled).

Any idea?

Regards,
Stefi



„Dave Peterson” ezt *rta:

> I've used this before, but it's untested, uncompiled here.
>
> Dim TestStr as string
> teststr = ""
> on error resume next
> teststr = dir("\\your\unc\path\here" & "\nul")
> on error goto 0
>
> if teststr = "" then
> 'not there
> else
> 'is there
> end if
>
>
>
> Chuck M wrote:
> >
> > Hi,
> >
> > I'm using a DIR command to verify that a folder exists on a local C: drive.
> > If I need to check a folder on a network drive, can I use the mapped drive
> > letter or must I supply a UNC path to the DIR command. I don't have the
> > resources to test this myself.
> >
> > TIA
> > --
> > Chuck M.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Jun 2008
Private Declare Function PathIsUNCServer Lib "shlwapi" _
Alias "PathIsUNCServerA" _
(ByVal pszPath As String) As Long


Public Function IsUNCPathAServer(ByVal sPath As String) As Boolean

IsUNCPathAServer = PathIsUNCServer(sPath) = 1
End Function


--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Stefi" <(E-Mail Removed)> wrote in message
news:9F8E2E6F-FB77-4C9B-A7C5-(E-Mail Removed)...
> Hi Dave,
>
> I was looking for a solution for checking the existence of a server and
> found this post of yours and hoped it helps me, but it doesn't. It returns
> a
> wrong False value if path to be checked consists of only the server name.
>
> My aim is to separate cases of non-existence of a folder:
>
> 1. The folder doesn't exist on an existing server.
> 2. The folder doesn't exist because the server itself doesn't exist (e.g.
> its name is mis-spelled).
>
> Any idea?
>
> Regards,
> Stefi
>
>
>
> "Dave Peterson" ezt rta:
>
>> I've used this before, but it's untested, uncompiled here.
>>
>> Dim TestStr as string
>> teststr = ""
>> on error resume next
>> teststr = dir("\\your\unc\path\here" & "\nul")
>> on error goto 0
>>
>> if teststr = "" then
>> 'not there
>> else
>> 'is there
>> end if
>>
>>
>>
>> Chuck M wrote:
>> >
>> > Hi,
>> >
>> > I'm using a DIR command to verify that a folder exists on a local C:
>> > drive.
>> > If I need to check a folder on a network drive, can I use the mapped
>> > drive
>> > letter or must I supply a UNC path to the DIR command. I don't have the
>> > resources to test this myself.
>> >
>> > TIA
>> > --
>> > Chuck M.

>>
>> --
>>
>> Dave Peterson
>>



 
Reply With Quote
 
Stefi
Guest
Posts: n/a
 
      3rd Jun 2008
Thank you Bob for your reply! It partly helped because it returns True for
any sPath meeting formal criteria (starting with \\) and False for
non-meeting ones but doesn't reflect that server sPath is a really existing
server or not.

Any further idea?

Regards,
Stefi


„Bob Phillips” ezt *rta:

> Private Declare Function PathIsUNCServer Lib "shlwapi" _
> Alias "PathIsUNCServerA" _
> (ByVal pszPath As String) As Long
>
>
> Public Function IsUNCPathAServer(ByVal sPath As String) As Boolean
>
> IsUNCPathAServer = PathIsUNCServer(sPath) = 1
> End Function
>
>
> --
> ---
> HTH
>
> Bob
>
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
>
>
> "Stefi" <(E-Mail Removed)> wrote in message
> news:9F8E2E6F-FB77-4C9B-A7C5-(E-Mail Removed)...
> > Hi Dave,
> >
> > I was looking for a solution for checking the existence of a server and
> > found this post of yours and hoped it helps me, but it doesn't. It returns
> > a
> > wrong False value if path to be checked consists of only the server name.
> >
> > My aim is to separate cases of non-existence of a folder:
> >
> > 1. The folder doesn't exist on an existing server.
> > 2. The folder doesn't exist because the server itself doesn't exist (e.g.
> > its name is mis-spelled).
> >
> > Any idea?
> >
> > Regards,
> > Stefi
> >
> >
> >
> > "Dave Peterson" ezt *rta:
> >
> >> I've used this before, but it's untested, uncompiled here.
> >>
> >> Dim TestStr as string
> >> teststr = ""
> >> on error resume next
> >> teststr = dir("\\your\unc\path\here" & "\nul")
> >> on error goto 0
> >>
> >> if teststr = "" then
> >> 'not there
> >> else
> >> 'is there
> >> end if
> >>
> >>
> >>
> >> Chuck M wrote:
> >> >
> >> > Hi,
> >> >
> >> > I'm using a DIR command to verify that a folder exists on a local C:
> >> > drive.
> >> > If I need to check a folder on a network drive, can I use the mapped
> >> > drive
> >> > letter or must I supply a UNC path to the DIR command. I don't have the
> >> > resources to test this myself.
> >> >
> >> > TIA
> >> > --
> >> > Chuck M.
> >>
> >> --
> >>
> >> Dave Peterson
> >>

>
>
>

 
Reply With Quote
 
Bob Phillips
Guest
Posts: n/a
 
      3rd Jun 2008
Just pass it the server, no other path, and see

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Stefi" <(E-Mail Removed)> wrote in message
news:C296A611-5B02-40A9-9F89-(E-Mail Removed)...
> Thank you Bob for your reply! It partly helped because it returns True for
> any sPath meeting formal criteria (starting with \\) and False for
> non-meeting ones but doesn't reflect that server sPath is a really
> existing
> server or not.
>
> Any further idea?
>
> Regards,
> Stefi
>
>
> "Bob Phillips" ezt rta:
>
>> Private Declare Function PathIsUNCServer Lib "shlwapi" _
>> Alias "PathIsUNCServerA" _
>> (ByVal pszPath As String) As Long
>>
>>
>> Public Function IsUNCPathAServer(ByVal sPath As String) As Boolean
>>
>> IsUNCPathAServer = PathIsUNCServer(sPath) = 1
>> End Function
>>
>>
>> --
>> ---
>> HTH
>>
>> Bob
>>
>>
>> (there's no email, no snail mail, but somewhere should be gmail in my
>> addy)
>>
>>
>>
>> "Stefi" <(E-Mail Removed)> wrote in message
>> news:9F8E2E6F-FB77-4C9B-A7C5-(E-Mail Removed)...
>> > Hi Dave,
>> >
>> > I was looking for a solution for checking the existence of a server and
>> > found this post of yours and hoped it helps me, but it doesn't. It
>> > returns
>> > a
>> > wrong False value if path to be checked consists of only the server
>> > name.
>> >
>> > My aim is to separate cases of non-existence of a folder:
>> >
>> > 1. The folder doesn't exist on an existing server.
>> > 2. The folder doesn't exist because the server itself doesn't exist
>> > (e.g.
>> > its name is mis-spelled).
>> >
>> > Any idea?
>> >
>> > Regards,
>> > Stefi
>> >
>> >
>> >
>> > "Dave Peterson" ezt rta:
>> >
>> >> I've used this before, but it's untested, uncompiled here.
>> >>
>> >> Dim TestStr as string
>> >> teststr = ""
>> >> on error resume next
>> >> teststr = dir("\\your\unc\path\here" & "\nul")
>> >> on error goto 0
>> >>
>> >> if teststr = "" then
>> >> 'not there
>> >> else
>> >> 'is there
>> >> end if
>> >>
>> >>
>> >>
>> >> Chuck M wrote:
>> >> >
>> >> > Hi,
>> >> >
>> >> > I'm using a DIR command to verify that a folder exists on a local C:
>> >> > drive.
>> >> > If I need to check a folder on a network drive, can I use the mapped
>> >> > drive
>> >> > letter or must I supply a UNC path to the DIR command. I don't have
>> >> > the
>> >> > resources to test this myself.
>> >> >
>> >> > TIA
>> >> > --
>> >> > Chuck M.
>> >>
>> >> --
>> >>
>> >> Dave Peterson
>> >>

>>
>>
>>



 
Reply With Quote
 
Stefi
Guest
Posts: n/a
 
      4th Jun 2008
I tried it again with this test macro:

Sub test6()
Dim uncserver As Boolean
Dim teststr As String
' teststr = "\\s00dt002"
teststr = "\s00dt002"
' teststr = "\\xxxxxxxx"

uncserver = False
uncserver = IsUNCPathAServer(teststr)
If uncserver Then
MsgBox teststr & " is there!"
Else
MsgBox teststr & " not there!"
End If
End Sub

"\\s00dt002" is an existing server, "\s00dt002" and "\\xxxxxxxx" are of
course not.

I get " is there!" message for "\\s00dt002" and "\\xxxxxxxx", " not there!"
for "\s00dt002".

What I'd like to achieve is getting
" is there!" message for "\\s00dt002
" not there!" for "\s00dt002" and "\\xxxxxxxx".

What do I do wrong?

Thanks,
Stefi



„Bob Phillips” ezt *rta:

> Just pass it the server, no other path, and see
>
> --
> ---
> HTH
>
> Bob
>
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
>
>
> "Stefi" <(E-Mail Removed)> wrote in message
> news:C296A611-5B02-40A9-9F89-(E-Mail Removed)...
> > Thank you Bob for your reply! It partly helped because it returns True for
> > any sPath meeting formal criteria (starting with \\) and False for
> > non-meeting ones but doesn't reflect that server sPath is a really
> > existing
> > server or not.
> >
> > Any further idea?
> >
> > Regards,
> > Stefi
> >
> >
> > "Bob Phillips" ezt *rta:
> >
> >> Private Declare Function PathIsUNCServer Lib "shlwapi" _
> >> Alias "PathIsUNCServerA" _
> >> (ByVal pszPath As String) As Long
> >>
> >>
> >> Public Function IsUNCPathAServer(ByVal sPath As String) As Boolean
> >>
> >> IsUNCPathAServer = PathIsUNCServer(sPath) = 1
> >> End Function
> >>
> >>
> >> --
> >> ---
> >> HTH
> >>
> >> Bob
> >>
> >>
> >> (there's no email, no snail mail, but somewhere should be gmail in my
> >> addy)
> >>
> >>
> >>
> >> "Stefi" <(E-Mail Removed)> wrote in message
> >> news:9F8E2E6F-FB77-4C9B-A7C5-(E-Mail Removed)...
> >> > Hi Dave,
> >> >
> >> > I was looking for a solution for checking the existence of a server and
> >> > found this post of yours and hoped it helps me, but it doesn't. It
> >> > returns
> >> > a
> >> > wrong False value if path to be checked consists of only the server
> >> > name.
> >> >
> >> > My aim is to separate cases of non-existence of a folder:
> >> >
> >> > 1. The folder doesn't exist on an existing server.
> >> > 2. The folder doesn't exist because the server itself doesn't exist
> >> > (e.g.
> >> > its name is mis-spelled).
> >> >
> >> > Any idea?
> >> >
> >> > Regards,
> >> > Stefi
> >> >
> >> >
> >> >
> >> > "Dave Peterson" ezt *rta:
> >> >
> >> >> I've used this before, but it's untested, uncompiled here.
> >> >>
> >> >> Dim TestStr as string
> >> >> teststr = ""
> >> >> on error resume next
> >> >> teststr = dir("\\your\unc\path\here" & "\nul")
> >> >> on error goto 0
> >> >>
> >> >> if teststr = "" then
> >> >> 'not there
> >> >> else
> >> >> 'is there
> >> >> end if
> >> >>
> >> >>
> >> >>
> >> >> Chuck M wrote:
> >> >> >
> >> >> > Hi,
> >> >> >
> >> >> > I'm using a DIR command to verify that a folder exists on a local C:
> >> >> > drive.
> >> >> > If I need to check a folder on a network drive, can I use the mapped
> >> >> > drive
> >> >> > letter or must I supply a UNC path to the DIR command. I don't have
> >> >> > the
> >> >> > resources to test this myself.
> >> >> >
> >> >> > TIA
> >> >> > --
> >> >> > Chuck M.
> >> >>
> >> >> --
> >> >>
> >> >> Dave Peterson
> >> >>
> >>
> >>
> >>

>
>
>

 
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
Outlook 2007--checking if a folder exists John Meyer Microsoft VB .NET 0 6th May 2010 02:11 PM
checking to see if DDL value exists Darrel Microsoft ASP .NET 4 10th Dec 2004 03:23 PM
checking to see if a folder exists Brian Henry Microsoft VB .NET 2 17th Nov 2004 08:08 AM
Checking if a folder exists liddlem Microsoft Word New Users 2 31st Dec 2003 09:09 AM
Checking to see if Folder exists Dan Microsoft Excel Programming 2 24th Sep 2003 02:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:54 AM.