none
Getting Directory Attributes RRS feed

  • Question

  • I want to get Attributes of Directory like file attributes.... and I want to check the system directory..


    How do I get the above thing...
    Thursday, October 29, 2009 4:14 AM

Answers

  • Hi Visweswaran,

    You can use DirectoryInfo class which is into system.IO namespace.
     
    its constructor takes path of the directory as an argument. Check out this link:

    http://msdn.microsoft.com/en-us/library/system.io.directoryinfo%28VS.71%29.aspx

    its members includes methods & properties to fetch attributes.

    regards,

    Vaibhav
    • Marked as answer by YiChun Chen Friday, October 30, 2009 10:03 AM
    Thursday, October 29, 2009 4:52 AM
  • you can use this class FileSystemInfo

    string[] drives = Directory.GetLogicalDrives();
    for (int i = 0; i < drives.Length; i++)
    {
    string _value = drives[i].ToString();
    DirectoryInfo dir=new DirectoryInfo(_value);
    foreach (FileSystemInfo fsi in dir.GetFileSystemInfos())
    {
      //if (fsi.Name != "System Volume Information")//System Information
    //{}
    //if(fsi is FileInfo)
    //{}
    if(fsi is DirectoryInfo)
    {}
    }
    }

    • Marked as answer by YiChun Chen Friday, October 30, 2009 10:03 AM
    Friday, October 30, 2009 4:39 AM

All replies

  • Hi Visweswaran,

    You can use DirectoryInfo class which is into system.IO namespace.
     
    its constructor takes path of the directory as an argument. Check out this link:

    http://msdn.microsoft.com/en-us/library/system.io.directoryinfo%28VS.71%29.aspx

    its members includes methods & properties to fetch attributes.

    regards,

    Vaibhav
    • Marked as answer by YiChun Chen Friday, October 30, 2009 10:03 AM
    Thursday, October 29, 2009 4:52 AM
  • you can use this class FileSystemInfo

    string[] drives = Directory.GetLogicalDrives();
    for (int i = 0; i < drives.Length; i++)
    {
    string _value = drives[i].ToString();
    DirectoryInfo dir=new DirectoryInfo(_value);
    foreach (FileSystemInfo fsi in dir.GetFileSystemInfos())
    {
      //if (fsi.Name != "System Volume Information")//System Information
    //{}
    //if(fsi is FileInfo)
    //{}
    if(fsi is DirectoryInfo)
    {}
    }
    }

    • Marked as answer by YiChun Chen Friday, October 30, 2009 10:03 AM
    Friday, October 30, 2009 4:39 AM