File.Exists Function

  • Thread starter Thread starter Smurfman-MSDN
  • Start date Start date
S

Smurfman-MSDN

Using VB2008 SP1 on Vista Ultimate x64 SP1

I have a service that is supposed to be polling a location on another server
using a simple

If File.Exists (xyz.file) then
Return True
Else
Return False
End If

I have found that if the Share is mapped to the computer where the service
is running such as "X:\filename" the service is not finding the file at the
location even though it exists.

HOWEVER, if I change the logic to be "\\UNC\Share\filename" the service
finds the file and can return a valid value.

Am I missing something as to why I cannot find a file on a mapped drive but
I can using a UNC name?

Thanks
J
 
Mapped network drive is only available to logged in user, be it mapped with
user logon script, or manully mapped and saved by windows user profile. A
winodws services runs without requirement of user being logged in, even the
account used to run the service can be a real user account. So, yes, you
should use UNC path with windows services.
 
Thanks Norman,
I will add that I found that UNC still only works if I hard code the
username and password of a user that can access the particular share on the
network.

J
 
It's not the password that is the problem - mapped files only exist for a
LOGGED on user. Services start before ANY user logs on, so there are NO
mapped files. You must use UNC forms. It's that simple.
Bob
 
Excellent! Thanks a bunch guys.

Bob Milton said:
It's not the password that is the problem - mapped files only exist for a
LOGGED on user. Services start before ANY user logs on, so there are NO
mapped files. You must use UNC forms. It's that simple.
Bob
 
Back
Top