2

I have a windows service that needs to access the files (sometime modification also) from a network (shared folder). I get the file name from an XML like,

<add key ="FolderName" value="\\192.168.0.1\Source" />

I made a log file which always shows that the path is not found.

Also i need to know how to debug a windows service using visual studio?

Thanks in advance.

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Shebin
  • 3,310
  • 2
  • 24
  • 27

1 Answers1

4

Most likely, the problem is in permissions to the shared folder. Your service runs under some user account and this account needs to have access granted to that folder. In case it's the 'Local Service' account you won't be able to access it. Just check under what account you run the service and whether it has access to that folder.

UPDATE: See this MSDN article for how to debug windows service applications.

Ondrej Tucny
  • 27,626
  • 6
  • 70
  • 90
  • user have access to that shared folder – Shebin May 16 '11 at 11:05
  • @Shebin: No, services don't run under any particular user's account. They run under their own account as a system process. You need to make sure that the system account has access to that folder, not a regular user. – Cody Gray - on strike May 16 '11 at 11:08
  • @Ondrej Tucny: The service is run as a system process,and the users a have access to that shared folder. – Shebin May 16 '11 at 11:12
  • Not sure what you're missing here... Whether or not the *users* have access to the shared folder is quite irrelevant. Glad I'm not the one that tried to answer this one. – Cody Gray - on strike May 16 '11 at 11:15
  • @Shebin: No need to tell *me* what I just told *you* ;-) Just go to Control panel — Administrative tools — Services and check under what account your service actually runs. – Ondrej Tucny May 16 '11 at 14:30
  • @Ondrej Tucny : in services i login as Local system account – Shebin May 17 '11 at 04:56
  • 3
    @Shebin: Well and there it is. 'Local System' has no access to network resources. http://msdn.microsoft.com/en-us/library/ms684190(v=vs.85).aspx – Ondrej Tucny May 17 '11 at 11:10
  • @Ondrej : could you please tell me how to debug a windows service using visual studio? – Shebin May 18 '11 at 11:11
  • @Shebin: Updated my answer accordingly. In case it helped you are free to update and/or accept my answer, by the way. – Ondrej Tucny May 18 '11 at 11:48