View Single Post
  #1 (permalink)  
Old March 28th, 2010, 08:26 PM
urbnsurfr urbnsurfr is offline
Registered User
 
Join Date: Mar 2010
Location: Indianapolis, IN
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default Access Denied on GetFiles()method

So far, I am finding this new book to be quite useful! I am having one problem I hope you can help me with. Referring to the section on file system objects, circa p. 778, you list an example program where you reference "foreach (DirectoryInfo nextFodler in theFolder.GetDirectories())".

If I attempt to use this code against my C:\users\owner\My Documents\ folder, I get an Access Denied error. If I instead poke into one of the subfolders and do directories there, I get no problems. Apparently there are system files hidden in this folder that cause GetFiles() and GetDirectories() to fail in Vista and Win7.

I have verified that I get this error in both 2008 and 2010 versions. Do you have any advice on how to work around this problem?

Kind Regards,
Dave Smith
Indianapolis, IN