public void Init() { Wait(true); //一覧情報の取得 var info = GetBrowseInfo("");//ドライブ情報 foreach(var str in info.Split('\t')) { var p = new OneBrowse(str);//オブジェクトを初期化 var browseImage = BrowseImage.DriveFixed; string name; switch(p.BrowseKind) { case BrowseKind.DriveFixed: name = string.Format(_kernel.IsJp() ? "ローカルディスク ({0})" : "LocalDisk ({0})", p.Name); break; case BrowseKind.DriveCdrom: name = string.Format(_kernel.IsJp() ? "DVD/DD RWドライブ ({0})" : "DVD/DD RW Drive ({0})", p.Name); break; case BrowseKind.DriveRemovable: name = string.Format(_kernel.IsJp() ? "リムーバブル ディスク ({0})" : "Removable Disk ({0})", p.Name); browseImage = BrowseImage.DriveCdrom; break; default: continue; } var node = treeView.Nodes.Add(name); node.ImageIndex = (int)browseImage; node.SelectedImageIndex = (int)browseImage; node.Tag = p.Name; } Wait(false); }
public void Init() { Wait(true); //一覧情報の取得 var info = GetBrowseInfo("");//ドライブ情報 foreach (var str in info.Split('\t')) { var p = new OneBrowse(str);//オブジェクトを初期化 var browseImage = BrowseImage.DriveFixed; string name; switch (p.BrowseKind) { case BrowseKind.DriveFixed: name = string.Format(_kernel.IsJp() ? "ローカルディスク ({0})" : "LocalDisk ({0})", p.Name); break; case BrowseKind.DriveCdrom: name = string.Format(_kernel.IsJp() ? "DVD/DD RWドライブ ({0})" : "DVD/DD RW Drive ({0})", p.Name); break; case BrowseKind.DriveRemovable: name = string.Format(_kernel.IsJp() ? "リムーバブル ディスク ({0})" : "Removable Disk ({0})", p.Name); browseImage = BrowseImage.DriveCdrom; break; default: continue; } var node = treeView.Nodes.Add(name); node.ImageIndex = (int)browseImage; node.SelectedImageIndex = (int)browseImage; node.Tag = p.Name; } Wait(false); }
//�f�B���N�g�����擾�i�����[�g�N���C�A���g�p�j public string GetBrowseInfo(string path) { var sb = new StringBuilder(); try{ if (path == ""){ //�h���C�u�ꗗ�擾 var drives = Directory.GetLogicalDrives(); foreach (string s in drives){ var driveName = s.ToUpper().Substring(0, 1); var info = new DriveInfo(driveName); var name = driveName + ":"; const int size = 0; var dt = new DateTime(0); BrowseKind browseKind; if (info.DriveType == DriveType.Fixed){ browseKind = BrowseKind.DriveFixed; } else if (info.DriveType == DriveType.CDRom){ browseKind = BrowseKind.DriveCdrom; } else if (info.DriveType == DriveType.Removable){ browseKind = BrowseKind.DriveRemovable; } else{ continue; } var p = new OneBrowse(browseKind, name, size, dt); //�P�f�[�^���� sb.Append(p + "\t"); //���M������ } } else{ string[] dirs = Directory.GetDirectories(path); Array.Sort(dirs); foreach (string s in dirs){ var name = s.Substring(path.Length); var info = new DirectoryInfo(s); const long size = 0; var dt = info.LastWriteTime; var p = new OneBrowse(BrowseKind.Dir, name, size, dt); //�P�f�[�^���� sb.Append(p + "\t"); //���M������ } var files = Directory.GetFiles(path); Array.Sort(files); foreach (var s in files){ var name = s.Substring(path.Length); var info = new FileInfo(s); var size = info.Length; var dt = info.LastWriteTime; var p = new OneBrowse(BrowseKind.File, name, size, dt); //�P�f�[�^���� sb.Append(p + "\t"); //���M������ } } } catch{ sb.Length = 0; } return sb.ToString(); }