Hi,
I developed a windows service to write PDF file in a directory. The service has no problem to write file in local drives. But when it tries to write in network mapped drive it failures and writes the file in application directory.
Hi,
I developed a windows service to write PDF file in a directory. The service has no problem to write file in local drives. But when it tries to write in network mapped drive it failures and writes the file in application directory.
Have you tried setting the write permission on the network drive to accept the user running the service?
Here are some experiences I had while creating the same service as you did (reading and saving PDF on a network drive). I had 2 drives: The first without the need of authentication and the second where you had to authenticate.
Common faults with mapped network drives
UNC Path vs Drive Letter: Drive letter's don't work, you have to specify your path using the UNC notation. (e.g. \\10.17.194.1\RemoteDir\)
Authentication: If the network drive needs you to authenticate, the only way I found was to create the authentication user on the machine running the service. If you need to authenticate as "RemoteUser" with "RemotePassword" to access the network drive, you should create a RemoteUser/RemotePassword account on the server and let the service run as this user.
If you don't have the rights to access the directory you'll be getting a exception telling you it could not find the directory/file or rather that it does not exist.
Service can't establish connection by itself: Also, it is mandatory to access the network drive at least once manually from the explorer so you can browse it. My service was unable to establish a connection to the network drive by itself, it had to be established in the explorer before.
I hope any of this points help you.
You need to make sure the account type the service is running as can access the network.
The 'Local System' user will probably not have permission to access the network mapped drive but could write to the local hard drive. You should be able to set the user the service is run as to one that has network share permissions.
I think that by default a windows service runs under the LocalService account so Services do not get any special priviledges by default. Maybe if you change the account of the service to the NetworkService account it will work.
I would check following:
Perhaps you have problems debugging the service: you can attach the debugger on it and then tell us which error you are getting. That will help the people here to help you.