cubaman
8/6/2008 8:24:00 AM
On Aug 4, 11:47 am, "Waldy" <some...@microsoft.com> wrote:
> Hi there,
> I have a C# Windows Service project that is checking a network
> share for new files and processing any that are found. The share has been
> given Full Control to the group Everyone. However, I am getting random
> behaviour where one time the code will work fine and the next time I will
> get an access denied error. What is going on?
>
> Message: Access to the path '\\Uksrvtl16a-6193\AATest' is denied.
> Source: mscorlib
> 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(String searchPattern)
> at
> Touchpaper.ActiveAssistance.OfflineController.FileProcessor.ProcessFiles(String
> DataFolder)
>
> The code I'm using is:
>
> protected String FindNextFile(String FolderName)
>
> {
>
> DirectoryInfo di = new DirectoryInfo(FolderName);
> FileInfo[] rgFiles = di.GetFiles("*.xml");
>
> if (rgFiles.Length > 0)
>
> {
>
> return rgFiles[0].FullName;
>
> }
>
> else
>
> {
>
> return null;
>
> }
> }
Hello:
Try assigning full trust to you application using .Net Framwork
configuration, in Code Access Security Policy section.
Best regards,
Oscar Acosta