I have a windows service on XP OS in .Net Framework 2.0 which access folder and reads file from it to load it in database.
Shared folder has permission for “Everyone” with full control with all subfolder. and service runs on “Local System Account”. and currently system running with Administrator account.
The stack trace is :
Message : Error while searching for files in : \\nw1\data\nov2012
Access to the path '\\nw1\data\nov2012' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles(String searchPattern, SearchOption searchOption)
at System.IO.DirectoryInfo.GetFiles()
at MyWinApp.Winservice1.SearchFiles(String imp, FileFolder objFile)
Edit: I found on MSDN that “LocalSystem Account has extensive privileges on the local computer” but not sure why it is not able to access network shared folder
can anyone suggest sollution for this problem?
Thanks,
I searched on internet but everywhere i found that anyhow i have to provide username/password to provide proper permission to windows service to access network shared folder(directly to windows service property or in windows service code like given here, code in that thread is here).
so to make it working it for now i set username/password manually to service property.