Example #1
0
        public void AddFolder(TreeListViewItem node, string fsFullPath, bool Recursive = false)
        {
            try
            {
                DirectoryInfo    diChild = new DirectoryInfo(fsFullPath);
                TreeListViewItem ndChild = new TreeListViewItem(diChild.Name);
                node.Items.Add(ndChild);
                if (node.CheckStatus != CheckState.Indeterminate)
                {
                    ndChild.Checked = node.Checked;
                }
                Apq.DllImports.Shell32.SHFILEINFO shFolderInfo = new DllImports.Shell32.SHFILEINFO();
                Apq.Windows.Forms.IconChache.GetFileSystemIcon(fsFullPath, ref shFolderInfo);
                ndChild.ImageKey = "文件夹收起";
                ndChild.SubItems.Add("0");
                ndChild.SubItems.Add(Apq.GlobalObject.UILang["文件夹"]);
                ndChild.SubItems.Add(diChild.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"));
                ndChild.SubItems.Add(diChild.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));

                ndChild.SubItems.Add(diChild.FullName);
                ndChild.SubItems.Add("0");
                ndChild.SubItems.Add("2");                //类型{1:Drive,2:Folder,3:File}

                if (Recursive)
                {
                    LoadChildren(ndChild, ndChild.FullPath, Recursive);
                }
            }
            catch { }
        }
Example #2
0
		public void AddFolder(TreeListViewItem node, string fsFullPath, bool Recursive = false)
		{
			try
			{
				DirectoryInfo diChild = new DirectoryInfo(fsFullPath);
				TreeListViewItem ndChild = new TreeListViewItem(diChild.Name);
				node.Items.Add(ndChild);
				if (node.CheckStatus != CheckState.Indeterminate)
				{
					ndChild.Checked = node.Checked;
				}
				Apq.DllImports.Shell32.SHFILEINFO shFolderInfo = new DllImports.Shell32.SHFILEINFO();
				Apq.Windows.Forms.IconChache.GetFileSystemIcon(fsFullPath, ref shFolderInfo);
				ndChild.ImageKey = "文件夹收起";
				ndChild.SubItems.Add("0");
				ndChild.SubItems.Add(Apq.GlobalObject.UILang["文件夹"]);
				ndChild.SubItems.Add(diChild.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"));
				ndChild.SubItems.Add(diChild.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));

				ndChild.SubItems.Add(diChild.FullName);
				ndChild.SubItems.Add("0");
				ndChild.SubItems.Add("2");//类型{1:Drive,2:Folder,3:File}

				if (Recursive)
				{
					LoadChildren(ndChild, ndChild.FullPath, Recursive);
				}
			}
			catch { }
		}
Example #3
0
        public void LoadDrives()
        {
            Apq.Windows.Delegates.Action_UI <FSExplorer>(this, this, delegate(FSExplorer ctrl)
            {
                // 取消监视
                foreach (Apq.IO.FsWatcher fsw in lstFsws)
                {
                    fsw.Created -= new FileSystemEventHandler(fsw_Created);
                    fsw.Renamed -= new RenamedEventHandler(fsw_Renamed);
                    fsw.Deleted -= new FileSystemEventHandler(fsw_Deleted);
                    fsw.Changed -= new FileSystemEventHandler(fsw_Changed);
                }
                lstFsws.Clear();

                // 为TreeListView添加根结点
                Items.Clear();
                //Items.SortOrder = SortOrder.None;

                DriveInfo[] fsDrives = DriveInfo.GetDrives();

                foreach (DriveInfo fsDrive in fsDrives)
                {
                    string strExt = fsDrive.Name;

                    TreeListViewItem ndRoot = new TreeListViewItem(fsDrive.Name.Substring(0, 2));
                    Items.Add(ndRoot);
                    Apq.DllImports.Shell32.SHFILEINFO shFileInfo = new DllImports.Shell32.SHFILEINFO();
                    Icon SmallIcon    = Apq.Windows.Forms.IconChache.GetFileSystemIcon(strExt, ref shFileInfo);
                    ndRoot.ImageIndex = _imgList.Images.IndexOfKey(shFileInfo.szTypeName);
                    if (fsDrive.IsReady)
                    {
                        ndRoot.SubItems.Add(fsDrive.TotalSize.ToString("n0"));
                    }
                    else
                    {
                        ndRoot.SubItems.Add("0");
                    }
                    ndRoot.SubItems.Add(shFileInfo.szTypeName);
                    ndRoot.SubItems.Add(fsDrive.RootDirectory.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"));
                    ndRoot.SubItems.Add(fsDrive.RootDirectory.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));

                    ndRoot.SubItems.Add(fsDrive.Name);
                    ndRoot.SubItems.Add(fsDrive.IsReady ? "0" : "-1");
                    ndRoot.SubItems.Add("1");                    //类型{1:Drive,2:Folder,3:File}

                    // 排序
                    //try { Items.Sort(false); }
                    //catch { }

                    // 添加监视器
                    if (fsDrive.IsReady)
                    {
                        Apq.IO.FsWatcher fsw               = new Apq.IO.FsWatcher();
                        fsw.FileSystemWatcher.Path         = fsDrive.RootDirectory.FullName;
                        fsw.FileSystemWatcher.NotifyFilter = NotifyFilters.CreationTime
                                                             | NotifyFilters.DirectoryName
                                                             | NotifyFilters.FileName
                                                             | NotifyFilters.LastWrite
                                                             | NotifyFilters.Size;
                        fsw.FileSystemWatcher.IncludeSubdirectories = true;
                        fsw.Created += new FileSystemEventHandler(fsw_Created);
                        fsw.Renamed += new RenamedEventHandler(fsw_Renamed);
                        fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
                        fsw.Changed += new FileSystemEventHandler(fsw_Changed);
                        lstFsws.Add(fsw);
                        fsw.Start();
                    }
                }
            });
        }
Example #4
0
		public void LoadDrives()
		{
			Apq.Windows.Delegates.Action_UI<FSExplorer>(this, this, delegate(FSExplorer ctrl)
			{
				// 取消监视
				foreach (Apq.IO.FsWatcher fsw in lstFsws)
				{
					fsw.Created -= new FileSystemEventHandler(fsw_Created);
					fsw.Renamed -= new RenamedEventHandler(fsw_Renamed);
					fsw.Deleted -= new FileSystemEventHandler(fsw_Deleted);
					fsw.Changed -= new FileSystemEventHandler(fsw_Changed);
				}
				lstFsws.Clear();

				// 为TreeListView添加根结点
				Items.Clear();
				//Items.SortOrder = SortOrder.None;

				DriveInfo[] fsDrives = DriveInfo.GetDrives();

				foreach (DriveInfo fsDrive in fsDrives)
				{
					string strExt = fsDrive.Name;

					TreeListViewItem ndRoot = new TreeListViewItem(fsDrive.Name.Substring(0, 2));
					Items.Add(ndRoot);
					Apq.DllImports.Shell32.SHFILEINFO shFileInfo = new DllImports.Shell32.SHFILEINFO();
					Icon SmallIcon = Apq.Windows.Forms.IconChache.GetFileSystemIcon(strExt, ref shFileInfo);
					ndRoot.ImageIndex = _imgList.Images.IndexOfKey(shFileInfo.szTypeName);
					if (fsDrive.IsReady)
					{
						ndRoot.SubItems.Add(fsDrive.TotalSize.ToString("n0"));
					}
					else
					{
						ndRoot.SubItems.Add("0");
					}
					ndRoot.SubItems.Add(shFileInfo.szTypeName);
					ndRoot.SubItems.Add(fsDrive.RootDirectory.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"));
					ndRoot.SubItems.Add(fsDrive.RootDirectory.LastWriteTime.ToString("yyyy-MM-dd HH:mm:ss"));

					ndRoot.SubItems.Add(fsDrive.Name);
					ndRoot.SubItems.Add(fsDrive.IsReady ? "0" : "-1");
					ndRoot.SubItems.Add("1");//类型{1:Drive,2:Folder,3:File}

					// 排序
					//try { Items.Sort(false); }
					//catch { }

					// 添加监视器
					if (fsDrive.IsReady)
					{
						Apq.IO.FsWatcher fsw = new Apq.IO.FsWatcher();
						fsw.FileSystemWatcher.Path = fsDrive.RootDirectory.FullName;
						fsw.FileSystemWatcher.NotifyFilter = NotifyFilters.CreationTime
							| NotifyFilters.DirectoryName
							| NotifyFilters.FileName
							| NotifyFilters.LastWrite
							| NotifyFilters.Size;
						fsw.FileSystemWatcher.IncludeSubdirectories = true;
						fsw.Created += new FileSystemEventHandler(fsw_Created);
						fsw.Renamed += new RenamedEventHandler(fsw_Renamed);
						fsw.Deleted += new FileSystemEventHandler(fsw_Deleted);
						fsw.Changed += new FileSystemEventHandler(fsw_Changed);
						lstFsws.Add(fsw);
						fsw.Start();
					}
				}
			});
		}