saeedtft

saeedtft

  • NA
  • 2
  • 0

ACCESS denied To A Folder

Dec 14 2004 4:45 PM
For Access To "System Volume Information" Directory , That this Directory Is In System Volumn , Under Error Is Occur An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll Additional information: Access to the path "I:\System Volume Information" is denied. private void GetDrive() { string[] ComDrv = Environment.GetLogicalDrives(); TreeNode Trn_Root = new TreeNode("MY Computer",2,2); TreeNode Trv_Drive; TreeNodeCollection TrvNode_Collect = Trn_Root.Nodes; foreach (string Drive in ComDrv) { if ((Drive == "A:\\") || (Drive == "B:\\")) { Trv_Drive = new TreeNode((string)Drive,3,3); } else { Trv_Drive = new TreeNode((string)Drive,0,1); } TreeNode Drv_Nodes = GetDir(Trv_Drive,Drive); Trn_Root.Nodes.Add(Drv_Nodes); } treeView1.Nodes.Add(Trn_Root); } private TreeNode GetDir(TreeNode Trv__Node,string Path) { if (Directory.Exists(Path) == false) { //MessageBox.Show("Directory or path " + Drive + " doesn't CONTENT","Windows Explorer - Error",MessageBoxButtons.OK,MessageBoxIcon.Stop); return Trv__Node; } DirectoryInfo DirInfo = new DirectoryInfo(Path); DirectoryInfo[] DirArrInfo = DirInfo.GetDirectories(); foreach (DirectoryInfo CurDir in DirArrInfo) { TreeNode Trv_Folder = new TreeNode(CurDir.Name,0,1); Trv__Node.Nodes.Add(Trv_Folder); GetDir(Trv_Folder,CurDir.FullName); } return Trv__Node; }