コード例 #1
0
        public DirectoryControll(DriveI info)
        {
            InitializeComponent();

            if (info.DriveType == DriveType.Fixed)
            {
                FixedDriveIcon.Opacity = 1;
            }
            else if (info.DriveType == DriveType.CDRom)
            {
                CDRoomIcon.Opacity = 1;
            }
            else if (info.DriveType == DriveType.Removable)
            {
                USBDriveIcon.Opacity = 1;
            }
            else
            {
                UnknownDriveIcon.Opacity = 1;
            }

            FullName          = info.Name;
            NameLabel.Content = info.Name;
            SizeLabel.Content = ToNormal(info.TotalSize) + " (" + ToNormal(info.AvailableFreeSpace) + " free)";
        }
コード例 #2
0
ファイル: DirMessage.cs プロジェクト: IPilin/FileSpy
        public DirMessage(string path)
        {
            try
            {
                Path = path;

                if (Path == "<drives>")
                {
                    Path = "";
                    var drives = DriveInfo.GetDrives();
                    int count  = 0;
                    for (int i = 0; i < drives.Length; i++)
                    {
                        if (drives[i].IsReady)
                        {
                            count++;
                        }
                    }
                    Drives = new DriveI[count];
                    for (int i = 0, id = 0; i < Drives.Length; i++)
                    {
                        if (drives[i].IsReady)
                        {
                            Drives[id] = new DriveI(drives[i]);
                            id++;
                        }
                    }
                    return;
                }

                DirectoryInfo dir  = new DirectoryInfo(Path);
                var           dirs = dir.GetDirectories();
                Directories = new DirectoryI[dirs.Length];
                for (int i = 0; i < Directories.Length; i++)
                {
                    Directories[i] = new DirectoryI(dirs[i]);
                }

                var files = dir.GetFiles();
                Files = new FileI[files.Length];
                for (int i = 0; i < Files.Length; i++)
                {
                    Files[i] = new FileI(files[i]);
                }
            }
            catch (Exception e)
            {
                Path = "<Error>\n" + e.Message;
            }
        }