Folder Not exist problem in windows service.

  • Thread starter Thread starter trialproduct2004
  • Start date Start date
T

trialproduct2004

hi all

i have one problem in windows service.

i have code as following:-

DirectoryInfo di = new DirectoryInfo(szfolder);
if(di.Exists==true)
eventLog1.WriteEntry("exist");
else
eventLog1.WriteEntry("not exist");

when i give szfolder as path of folder which on lan something like
"\\aa\bb",
where aa is some other computer on lan which is accessiable through my
pc.

above code add entry in log as 'not exist'.

but if i try same code with windows application ' it will display
message as 'exist'./

can some one tell me why this is happening.

any help will be appreciated.

thanks in advance.
 
hi all

i have one problem in windows service.

i have code as following:-

DirectoryInfo di = new DirectoryInfo(szfolder);
if(di.Exists==true)
eventLog1.WriteEntry("exist");
else
eventLog1.WriteEntry("not exist");

when i give szfolder as path of folder which on lan something like
"\\aa\bb",
where aa is some other computer on lan which is accessiable through my
pc.

Network shares are not "accessible" from a pc, they are "accesible" from
user logon sessions, and unless your service runs as a user that has access
to the remote share, it won't be able to access the share, even if the
interactive user logon has access.
So make sure that you run your service as a user with access privileges to
the remote share. Note that service accounts like SYSTEM, NETWORK_SERVICE
and LOCAL SERVICE are local accounts, so don't have network access
privileges, though they can be used to access remote shares when running in
a Kerberos real (W2K AD).

Willy.
 
Hi

thanks for your reply.

Does i have to set accout type as user.

Can u tell me how to run service as a user with access privileges to
remote share.

Because currently my service type is local system

Thanks
 
Hi

thanks for your reply.

Does i have to set accout type as user.

Can u tell me how to run service as a user with access privileges to
remote share.

Because currently my service type is local system

Thanks

Run your service as a domain user, if you aren't running in a domain, you'll
need to create a shadow account (both servers have the same user name with
the same password). To test this you can change your service account through
the services applet.

Willy.
 
Back
Top