manoj sawant
manoj sawant

Reputation: 15

Window service unable to access remote shared folder

I have created a window service in C# 4.0, I have a piece of code to read a file located at remote server. When i try to access that file, I get a error as "Folder does not exist c:/xxx.xx.xx.xx/sharedfolder".

    foreach (string subdirectory in Directory.GetDirectories("\\xxx.xx.xx\sharedfolder"))
{

}

But if i run same piece of code on console application it is able to access that folder how i can get rid of it.

Upvotes: 0

Views: 3219

Answers (1)

TheGeneral
TheGeneral

Reputation: 81473

Running a service under the default Local System Account, will have no concept of the share. These are set up under user accounts.

Your 2 options

  1. Run your service under a User Account which has those shares mapped
  2. Access your share via and unc/ip address instead of the share name/drive letter. However, you will need to set the file/folder permissions accordingly.

Upvotes: 3

Related Questions