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.
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.
来源:https://stackoverflow.com/questions/6016388/accessing-shared-folder-over-a-network-in-windows-service