Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - File.Exists Function

Reply
 
Old 03-26-2009   #1 (permalink)
Smurfman-MSDN


 
 

File.Exists Function

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

My System SpecsSystem Spec
Old 03-26-2009   #2 (permalink)
Norman Yuan


 
 

Re: File.Exists Function

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.

"Smurfman-MSDN" <smurfman@xxxxxx> wrote in message
news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx
Quote:

> 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
My System SpecsSystem Spec
Old 03-26-2009   #3 (permalink)
Smurfman-MSDN


 
 

Re: File.Exists Function

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

"Norman Yuan" wrote:
Quote:

> 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.
>
> "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message
> news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx
Quote:

> > 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
>
>
My System SpecsSystem Spec
Old 03-27-2009   #4 (permalink)
Bob Milton


 
 

Re: File.Exists Function

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

"Smurfman-MSDN" <smurfman@xxxxxx> wrote in message
news:31B4C0E9-F711-45BA-BB7F-E30782924135@xxxxxx
Quote:

> 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
>
> "Norman Yuan" wrote:
>
Quote:

>> 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.
>>
>> "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message
>> news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx
Quote:

>> > 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
>>
>>

My System SpecsSystem Spec
Old 03-27-2009   #5 (permalink)
Smurfman-MSDN


 
 

Re: File.Exists Function

Excellent! Thanks a bunch guys.

"Bob Milton" wrote:
Quote:

> 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
>
> "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message
> news:31B4C0E9-F711-45BA-BB7F-E30782924135@xxxxxx
Quote:

> > 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
> >
> > "Norman Yuan" wrote:
> >
Quote:

> >> 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.
> >>
> >> "Smurfman-MSDN" <smurfman@xxxxxx> wrote in message
> >> news:F6447B79-D1BF-4DAB-8919-1D0B3CE2E6BD@xxxxxx
> >> > 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
> >>
> >>
>
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Copy File to users home drives if a certain file exists VB Script
if a file exists PowerShell
If file exists loop PowerShell
is there an 'exists-item' function? PowerShell
BUG: Redirecting function contents to a file truncates function lines at the width of the console PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46