[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

Random behaviour accessing a share

msnews.microsoft.com

8/4/2008 9:48:00 AM

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;

}

}


1 Answer

cubaman

8/6/2008 8:24:00 AM

0

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