'Unauthorized Access Exception' when trying to delete folder created from code using C#:
If you have created a folder via code, then folder's readonly attributes gets setup. Now in order to delete it from code, one needs to remove the readonly attribute first. If not done,it will throw an Unauthorized Access Exception
If you have a file inside the folder with readonly attribute, then also it will result in same exception.
Folder.Attributes = Folder.Attributes & ~System.IO.FileAttributes.ReadOnly;
FileInfo files = Folder.GetFiles();
Array.ForEach(files, new Action(f =>
Hope you find this useful.