View Single Post
  #3 (permalink)  
Old October 8th, 2010, 09:50 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 It seems to be the difference in how we call the directory

source_dir "C:\\Users\\noz\\My Documents" string
DirectoryInfo sd = new DirectoryInfo(source_dir);

foreach (DirectoryInfo nextFolder in sd.GetDirectories())
FileInfo[] files = sd.GetFiles();

In the GetDirectories() and the GetFiles() method I get the same error:
Access to the path 'C:\Users\noz\My Documents\' is denied.

However, if I instanatiate the way you made it (with the environment call):

sd = new DirectoryInfo(Environment.GetFolderPath(Environmen t.SpecialFolder.MyDocuments));

With sd instantiated this way, I do not get the access denied error. So I guess that's my way around the problem. Thanks for your help!

Kind Regards,
Dave Smith