在窗口服务访问共享文件夹在网络上共享文件夹、窗口、网络

2023-09-03 06:28:59 作者:有趣的二货

我有一个需要从网络(共享文件夹)访问这些文件(有时也修改),一个窗口服务。我从XML得到的文件名一样,

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.

此外,我需要知道如何使用Visual Studio调试Windows服务?

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

在此先感谢。

推荐答案

最有可能的,问题是权限的共享文件夹。您的服务在一些用户帐户运行,该帐户需要有该文件夹授予访问权限。在情况下,它的本地服务帐户,您将无法访问它。只是检查在什么样的帐户运行服务,是否有访问该文件夹。

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.

更新:请参见这个MSDN文章如何调试Windows服务应用程序。

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