I created a Windows executable by developing a very simple .NET console application in Visual Studio. The executable opens up a mapped drive and reads the files from that mapped drive. The mapped drive points to a UNC path (ie: \\uncpath\uncpath\etc...). I know my user has permissions to that mapped drive because I created it. When I run the *.exe file, I get this exception, which from what I've read, is the result of permissions issues. How can I allow read access to that mapped drive from the program? Note, this exe runs fine in Windows XP. The problem results after deploying to Windows Server 2008. I have not tried Windows 7, but I will do that next.
As a side note, I'm also wanting to schedule this via Windows Task Scheduler, but I believe there's a way to set a Windows user on the task during task creation. I'm not using the Windows Task Scheduler thought yet. The exception below happens when running manually when logged into Windows Server 2008 when using my Windows account.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileSystemEnumerableIterator`1.CommonInit() at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler) at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal, String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption) at System.IO.Directory.GetFiles(String path) at LdwMonitor.Program.ScanLdwLogs() in C:\Source\HimcMonitor\LdwMonitor\Program.cs:line 83 at LdwMonitor.Program.Main(String args) in C:\Source\HimcMonitor\LdwMonitor\Program.cs:line 17
Source code throwing the exception:
string fileEntries = Directory.GetFiles(rootDir);