How to check for this file path? 
Author Message
 How to check for this file path?

How do I check if a file exists if the filepath is given like this:

servername:serverdrive:\folder\file

where server drive is the local drive name, so usually C

RBS



Thu, 17 Feb 2011 04:00:57 GMT  
 How to check for this file path?
From MSDN.
The following procedure returns true if the specified file exists and false if it does not, but doesn't
contain error-handling code:

Function FileExists (filename) As Boolean
   FileExists = (Dir(filename) <> "")
End Function

--

Steve Easton

Quote:

> How do I check if a file exists if the filepath is given like this:

> servername:serverdrive:\folder\file

> where server drive is the local drive name, so usually C

> RBS



Thu, 17 Feb 2011 04:57:26 GMT  
 How to check for this file path?
But that will give False or an error with that kind of file path.

I have also tried these 2:

Private Declare Function PathFileExists Lib "shlwapi" _
                                        Alias "PathFileExistsA" _
                                        (ByVal pszPath As String) As Long

Function bFileExists2(sFile As String) As Boolean

  bFileExists2 = PathFileExists(sFile) = 1

End Function

Function bFileExists(ByVal sFile As String) As Boolean

  Dim lAttr As Long

  On Error Resume Next
  lAttr = GetAttr(sFile)
  bFileExists = (Err.Number = 0) And ((lAttr And vbDirectory) = 0)
  On Error GoTo 0

End Function

But they will give False as well with that type of path.

RBS


Quote:
> From MSDN.
> The following procedure returns true if the specified file exists and
> false if it does not, but doesn't contain error-handling code:

> Function FileExists (filename) As Boolean
>   FileExists = (Dir(filename) <> "")
> End Function

> --

> Steve Easton



>> How do I check if a file exists if the filepath is given like this:

>> servername:serverdrive:\folder\file

>> where server drive is the local drive name, so usually C

>> RBS



Thu, 17 Feb 2011 05:15:13 GMT  
 How to check for this file path?
Shouldn't the path be given as \\servername\serverdrive\folder\file ?

/Henning



Quote:
> From MSDN.
> The following procedure returns true if the specified file exists and
> false if it does not, but doesn't contain error-handling code:

> Function FileExists (filename) As Boolean
>   FileExists = (Dir(filename) <> "")
> End Function

> --

> Steve Easton



>> How do I check if a file exists if the filepath is given like this:

>> servername:serverdrive:\folder\file

>> where server drive is the local drive name, so usually C

>> RBS



Thu, 17 Feb 2011 07:03:08 GMT  
 How to check for this file path?
That is the path I have to deal with and it does work as I can use it in a
.bat file and no error occurs.
In any case it will give False even with the
\\servername\serverdrive\folder\file path.

RBS


Quote:
> Shouldn't the path be given as \\servername\serverdrive\folder\file ?

> /Henning



>> From MSDN.
>> The following procedure returns true if the specified file exists and
>> false if it does not, but doesn't contain error-handling code:

>> Function FileExists (filename) As Boolean
>>   FileExists = (Dir(filename) <> "")
>> End Function

>> --

>> Steve Easton



>>> How do I check if a file exists if the filepath is given like this:

>>> servername:serverdrive:\folder\file

>>> where server drive is the local drive name, so usually C

>>> RBS



Thu, 17 Feb 2011 07:11:23 GMT  
 How to check for this file path?


Quote:
> That is the path I have to deal with and it does work as I can use it in a
> .bat file and no error occurs.
> In any case it will give False even with the
> \\servername\serverdrive\folder\file path.

try \\servername\serverdrive$\folderpath\filename

note the $

you will need administrative rights to the target machine for that to work



Thu, 17 Feb 2011 07:20:17 GMT  
 How to check for this file path?
Also beware that serverdrive has no colon(:)

/Henning



Quote:
> That is the path I have to deal with and it does work as I can use it in a
> .bat file and no error occurs.
> In any case it will give False even with the
> \\servername\serverdrive\folder\file path.

> RBS



>> Shouldn't the path be given as \\servername\serverdrive\folder\file ?

>> /Henning



>>> From MSDN.
>>> The following procedure returns true if the specified file exists and
>>> false if it does not, but doesn't contain error-handling code:

>>> Function FileExists (filename) As Boolean
>>>   FileExists = (Dir(filename) <> "")
>>> End Function

>>> --

>>> Steve Easton



>>>> How do I check if a file exists if the filepath is given like this:

>>>> servername:serverdrive:\folder\file

>>>> where server drive is the local drive name, so usually C

>>>> RBS



Thu, 17 Feb 2011 07:39:01 GMT  
 How to check for this file path?
Thanks for the suggestions, but I can't get it to work when I have the
server name in the path.
Will do some further Googling.

RBS


Quote:
> Also beware that serverdrive has no colon(:)

> /Henning



>> That is the path I have to deal with and it does work as I can use it in
>> a .bat file and no error occurs.
>> In any case it will give False even with the
>> \\servername\serverdrive\folder\file path.

>> RBS



>>> Shouldn't the path be given as \\servername\serverdrive\folder\file ?

>>> /Henning



>>>> From MSDN.
>>>> The following procedure returns true if the specified file exists and
>>>> false if it does not, but doesn't contain error-handling code:

>>>> Function FileExists (filename) As Boolean
>>>>   FileExists = (Dir(filename) <> "")
>>>> End Function

>>>> --

>>>> Steve Easton



>>>>> How do I check if a file exists if the filepath is given like this:

>>>>> servername:serverdrive:\folder\file

>>>>> where server drive is the local drive name, so usually C

>>>>> RBS



Thu, 17 Feb 2011 17:02:48 GMT  
 How to check for this file path?
Asking the obvious, but have you the exact path it in a command promt?

/Henning



Quote:
> Thanks for the suggestions, but I can't get it to work when I have the
> server name in the path.
> Will do some further Googling.

> RBS



>> Also beware that serverdrive has no colon(:)

>> /Henning



>>> That is the path I have to deal with and it does work as I can use it in
>>> a .bat file and no error occurs.
>>> In any case it will give False even with the
>>> \\servername\serverdrive\folder\file path.

>>> RBS



>>>> Shouldn't the path be given as \\servername\serverdrive\folder\file ?

>>>> /Henning



>>>>> From MSDN.
>>>>> The following procedure returns true if the specified file exists and
>>>>> false if it does not, but doesn't contain error-handling code:

>>>>> Function FileExists (filename) As Boolean
>>>>>   FileExists = (Dir(filename) <> "")
>>>>> End Function

>>>>> --

>>>>> Steve Easton



>>>>>> How do I check if a file exists if the filepath is given like this:

>>>>>> servername:serverdrive:\folder\file

>>>>>> where server drive is the local drive name, so usually C

>>>>>> RBS



Thu, 17 Feb 2011 19:23:11 GMT  
 How to check for this file path?
Yes, have checked several times.
Probably I am overlooking something simple somewhere.

RBS


Quote:
> Asking the obvious, but have you the exact path it in a command promt?

> /Henning



>> Thanks for the suggestions, but I can't get it to work when I have the
>> server name in the path.
>> Will do some further Googling.

>> RBS



>>> Also beware that serverdrive has no colon(:)

>>> /Henning



>>>> That is the path I have to deal with and it does work as I can use it
>>>> in a .bat file and no error occurs.
>>>> In any case it will give False even with the
>>>> \\servername\serverdrive\folder\file path.

>>>> RBS



>>>>> Shouldn't the path be given as \\servername\serverdrive\folder\file ?

>>>>> /Henning



>>>>>> From MSDN.
>>>>>> The following procedure returns true if the specified file exists and
>>>>>> false if it does not, but doesn't contain error-handling code:

>>>>>> Function FileExists (filename) As Boolean
>>>>>>   FileExists = (Dir(filename) <> "")
>>>>>> End Function

>>>>>> --

>>>>>> Steve Easton



>>>>>>> How do I check if a file exists if the filepath is given like this:

>>>>>>> servername:serverdrive:\folder\file

>>>>>>> where server drive is the local drive name, so usually C

>>>>>>> RBS



Thu, 17 Feb 2011 19:40:19 GMT  
 How to check for this file path?


Quote:
> Yes, have checked several times.
> Probably I am overlooking something simple somewhere.

> RBS

It has been my experience that support for UNC is inconsistent across
platforms, libraries, and configurations (permissions, share, AD, etc). You
will find the web littered with work-arounds for resolving the location for
specific situations.

Just for grins try replacing with the IP address.

-ralph



Thu, 17 Feb 2011 23:53:20 GMT  
 How to check for this file path?
C$ share may not be there - I think it can be removed...

Steve Mussler


Quote:
> Yes, have checked several times.
> Probably I am overlooking something simple somewhere.

> RBS



>> Asking the obvious, but have you the exact path it in a command promt?

>> /Henning



>>> Thanks for the suggestions, but I can't get it to work when I have the
>>> server name in the path.
>>> Will do some further Googling.

>>> RBS



>>>> Also beware that serverdrive has no colon(:)

>>>> /Henning



>>>>> That is the path I have to deal with and it does work as I can use it
>>>>> in a .bat file and no error occurs.
>>>>> In any case it will give False even with the
>>>>> \\servername\serverdrive\folder\file path.

>>>>> RBS



>>>>>> Shouldn't the path be given as \\servername\serverdrive\folder\file ?

>>>>>> /Henning



>>>>>>> From MSDN.
>>>>>>> The following procedure returns true if the specified file exists
>>>>>>> and false if it does not, but doesn't contain error-handling code:

>>>>>>> Function FileExists (filename) As Boolean
>>>>>>>   FileExists = (Dir(filename) <> "")
>>>>>>> End Function

>>>>>>> --

>>>>>>> Steve Easton



>>>>>>>> How do I check if a file exists if the filepath is given like this:

>>>>>>>> servername:serverdrive:\folder\file

>>>>>>>> where server drive is the local drive name, so usually C

>>>>>>>> RBS



Fri, 18 Feb 2011 08:45:56 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Paths -- Creating File Path with several levels -- VBScript

2. Dir Path Or File Path

3. Checking if folder/path exists: Outlook Form

4. how to check application path?

5. Check if path exists

6. How to check if a path exists

7. How to check if a program is installed (or find it's path)

8. Check for valid path in class Property Let

9. Check if UNC path exists

10. How can I check a valid path?`

11. Find the file path of a program file

12. Full path, and file information of all files on the computer

 

 
Powered by phpBB® Forum Software