广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >基于C#实现获取本地磁盘目录
  • 674
分享到

基于C#实现获取本地磁盘目录

C#获取本地磁盘目录C#获取磁盘目录C#磁盘目录 2022-12-26 12:12:31 674人浏览 薄情痞子
摘要

目录实践过程效果代码实践过程 效果 代码 class BaseClass { public class Win32 { public const u

实践过程

效果

代码

class BaseClass
{
    public class Win32
    {
        public const uint SHGFI_ICON = 0x100;
        public const uint SHGFI_LARGEICON = 0x0; // 'Large icon
        public const uint SHGFI_SMALLICON = 0x1; // 'Small icon
        [DllImport("shell32.dll", EntryPoint = "ExtractIcon")]
        public static extern int ExtractIcon(IntPtr hInst, string lpFileName, int nIndex);
        [DllImport("shell32.dll", EntryPoint = "SHGetFileInfo")]
        public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttribute, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint Flags);
        [DllImport("User32.dll", EntryPoint = "DestroyIcon")]
        public static extern int DestroyIcon(IntPtr hIcon);
        [DllImport("shell32.dll")]
        public static extern uint ExtractIconEx(string lpszFile, int nIconIndex, int[] phiconLarge, int[] phiconSmall, uint nIcons);
        [StructLayout(LayoutKind.Sequential)]
        public struct SHFILEINFO
        {
            public IntPtr hIcon;
            public IntPtr iIcon;
            public uint dwAttributes;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
            public string szDisplayName;
            [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
            public string szTypeName;
        }
    }

    #region  文件夹的复制
    /// <summary>
    /// 文件夹的复制
    /// </summary>
    /// <param Ddir="string">要复制的目的路径</param>
    /// <param Sdir="string">要复制的原路径</param>
    public void Files_Copy(string Ddir, string Sdir)
    {
        DirectoryInfo dir = new DirectoryInfo(Sdir);
        string SbuDir = Ddir;
        try
        {
            if (!dir.Exists)//判断所指的文件或文件夹是否存在
            {
                return;
            }
            DirectoryInfo dirD = dir as DirectoryInfo;//如果给定参数不是文件夹则退出
            string UpDir = UpAndDown_Dir(Ddir);
            if (dirD == null)//判断文件夹是否为空
            {
                Directory.CreateDirectory(UpDir + "\\" + dirD.Name);//如果为空,创建文件夹并退出
                return;
            }
            else
            {
                Directory.CreateDirectory(UpDir + "\\" + dirD.Name);
            }
            SbuDir = UpDir + "\\" + dirD.Name + "\\";
            FileSystemInfo[] files = dirD.GetFileSystemInfos();//获取文件夹中所有文件和文件夹
            //对单个FileSystemInfo进行判断,如果是文件夹则进行递归操作
            foreach (FileSystemInfo FSys in files)
            {
                FileInfo file = FSys as FileInfo;
                if (file != null)//如果是文件的话,进行文件的复制操作
                {
                    FileInfo SFInfo = new FileInfo(file.DirectoryName + "\\" + file.Name);//获取文件所在的原始路径
                    SFInfo.CopyTo(SbuDir + "\\" + file.Name, true);//将文件复制到指定的路径中
                }
                else
                {
                    string pp = FSys.Name;//获取当前搜索到的文件夹名称
                    Files_Copy(SbuDir + FSys.ToString(), Sdir + "\\" + FSys.ToString());//如果是文件,则进行递归调用
                }
            }
        }
        catch
        {
            MessageBox.Show("文件制复失败。");
            return;
        }
    }
    #endregion

    #region  返回上一级目录
    /// <summary>
    /// 返回上一级目录
    /// </summary>
    /// <param dir="string">目录</param>
    /// <returns>返回String对象</returns>
    public string UpAndDown_Dir(string dir)
    {
        string Change_dir = "";
        Change_dir = Directory.GetParent(dir).FullName;
        return Change_dir;
    }
    #endregion

    public void listFolders(ToolStripComboBox tscb)//获取本地磁盘目录
    {
        string[] logicdrives = System.IO.Directory.GetLogicalDrives();
        for (int i = 0; i < logicdrives.Length; i++)
        {
            tscb.Items.Add(logicdrives[i]);
            tscb.SelectedIndex = 0;
        }
    }
    int k = 0;
    public void GoBack(ListView lv,ImageList il,string path)
    {

        if (AllPath.Length != 3)
        {
            string NewPath = AllPath.Remove(AllPath.LastIndexOf("\\")).Remove(AllPath.Remove(AllPath.LastIndexOf("\\")).LastIndexOf("\\")) + "\\";
            lv.Items.Clear();
            GetListViewItem(NewPath, il, lv);
            AllPath = NewPath;
        }
        else
        {
            if (k == 0)
            {
                lv.Items.Clear();
                GetListViewItem(path, il, lv);
                k++;
            }
        }
    }
    public string Mpath()
    {
        string path=AllPath;
        return path;
    }
    public static string AllPath = "";//---------
    public void GetPath(string path, ImageList imglist, ListView lv,int ppath)//-------
    {
            string pp = "";
            string uu = "";
            if (ppath == 0)
            {
                if (AllPath != path)
                {
                    lv.Items.Clear();
                    AllPath = path;
                    GetListViewItem(AllPath, imglist, lv);
                }
            }
            else
            {
                uu = AllPath + path;
                if (Directory.Exists(uu))
                {
                    AllPath = AllPath + path + "\\";
                    pp = AllPath.Substring(0, AllPath.Length - 1);
                    lv.Items.Clear();
                    GetListViewItem(pp, imglist, lv);
                }
                else
                {
                    uu = AllPath + path;
                    System.Diagnostics.Process.Start(uu);
                }
            }
    }
    public void GetListViewItem(string path, ImageList imglist, ListView lv)//获取指定路径下所有文件及其图标
    {
        lv.Items.Clear();
        Win32.SHFILEINFO shfi = new Win32.SHFILEINFO();
        try
        {
            string[] dirs = Directory.GetDirectories(path);
            string[] files = Directory.GetFiles(path);
            for (int i = 0; i < dirs.Length; i++)
            {
                string[] info = new string[4];
                DirectoryInfo dir = new DirectoryInfo(dirs[i]);
                if (dir.Name == "RECYCLER" || dir.Name == "RECYCLED" || dir.Name == "Recycled" || dir.Name == "System Volume InfORMation")
                { }
                else
                {
                    //获得图标
                    Win32.SHGetFileInfo(dirs[i],
                                        (uint)0x80,
                                        ref shfi,
                                        (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi),
                                        (uint)(0x100 | 0x400)); //取得Icon和TypeName
                    //添加图标
                    imglist.Images.Add(dir.Name, (Icon)Icon.FromHandle(shfi.hIcon).Clone());
                    info[0] = dir.Name;
                    info[1] = "";
                    info[2] = "文件夹";
                    info[3] = dir.LastWriteTime.ToString();
                    ListViewItem item = new ListViewItem(info, dir.Name);
                    lv.Items.Add(item);
                    //销毁图标
                    Win32.DestroyIcon(shfi.hIcon);
                }
            }
            for (int i = 0; i < files.Length; i++)
            {
                string[] info = new string[4];
                FileInfo fi = new FileInfo(files[i]);
                string Filetype = fi.Name.Substring(fi.Name.LastIndexOf(".")+1,fi.Name.Length- fi.Name.LastIndexOf(".") -1);
                string newtype=Filetype.ToLower();
                if (newtype == "sys" || newtype == "ini" || newtype == "bin" || newtype == "log" || newtype == "com" || newtype == "bat" || newtype == "db")
                { }
                else
                {


                    //获得图标
                    Win32.SHGetFileInfo(files[i],
                                        (uint)0x80,
                                        ref shfi,
                                        (uint)System.Runtime.InteropServices.Marshal.SizeOf(shfi),
                                        (uint)(0x100 | 0x400)); //取得Icon和TypeName
                    //添加图标
                    imglist.Images.Add(fi.Name, (Icon)Icon.FromHandle(shfi.hIcon).Clone());
                    info[0] = fi.Name;
                    info[1] = fi.Length.ToString();
                    info[2] = fi.Extension.ToString();
                    info[3] = fi.LastWriteTime.ToString();
                    ListViewItem item = new ListViewItem(info, fi.Name);
                    lv.Items.Add(item);
                    //销毁图标
                    Win32.DestroyIcon(shfi.hIcon);
                }
            }
        }
        catch
        {
        }
    }
}
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    BaseClass bc = new BaseClass();
    private void Form1_Load(object sender, EventArgs e)
    {
        bc.listFolders(toolStripComboBox1);
    }

    private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        bc.GetPath(toolStripComboBox1.Text, imageList1, listView1, 0);
    }

    private void listView1_DoubleClick(object sender, EventArgs e)
    {
        try
        {
            string pp = listView1.SelectedItems[0].Text;
            bc.GetPath(pp.Trim(), imageList1, listView1, 1);
        }
        catch
        {
            MessageBox.Show("无法打开此文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }

    private void toolStripButton2_Click(object sender, EventArgs e)
    {
        bc.GOBack(listView1, imageList1, toolStripComboBox1.Text);
    }
    private int T = 0;
    private string path;
    private static string MyPath;
    private static ArrayList al = new ArrayList();
    private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (listView1.SelectedItems.Count != 0)
        {
            al.Clear();
            for (int i = 0; i < listView1.SelectedItems.Count; i++)
            {
                al.Add(bc.Mpath() + "\\" + listView1.SelectedItems[i].Text);
            }
            T = 0;
        }
    }

    private void 复制ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        try
        {
            al.Clear();
            path = bc.Mpath() + "\\" + listView1.SelectedItems[0].Text;
            for (int i = 0; i < listView1.SelectedItems.Count; i++)
            {
                al.Add(bc.Mpath() + "\\" + listView1.SelectedItems[i].Text);
            }
            System.Collections.Specialized.StrinGCollection files = new System.Collections.Specialized.StringCollection();
            files.Add(path);
            Clipboard.SetFileDropList(files);
            MyPath = path;
            T = 1;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }

    private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (T == 0)
        {
            try
            {
                for (int i = 0; i < al.Count; i++)
                {
                    string name1 = al[i].ToString().Substring(al[i].ToString().LastIndexOf("\\") + 1, al[i].ToString().Length - al[i].ToString().LastIndexOf("\\") - 1);
                    string paths = bc.Mpath() + "\\" + name1;
                    if (File.Exists(al[i].ToString()))
                    {
                        if (al[i].ToString() != paths)
                        {
                            File.Move(al[i].ToString(), paths);
                        }
                    }
                    if (Directory.Exists(al[i].ToString()))
                    {
                        bc.Files_Copy(paths, al[i].ToString());
                        DirectoryInfo di = new DirectoryInfo(al[i].ToString());
                        di.Delete(true);
                    }
                }
                listView1.Items.Clear();
                bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        else
        {
            try
            {
                for (int i = 0; i < al.Count; i++)
                {
                    string name1 = al[i].ToString().Substring(al[i].ToString().LastIndexOf("\\") + 1, al[i].ToString().Length - al[i].ToString().LastIndexOf("\\") - 1);
                    string paths = bc.Mpath() + "\\" + name1;
                    if (File.Exists(al[i].ToString()))
                    {
                        if (al[i].ToString() != paths)
                        {
                            File.Copy(al[i].ToString(), paths, false);
                        }
                    }
                    if (Directory.Exists(al[i].ToString()))
                    {
                        bc.Files_Copy(paths, al[i].ToString());
                    }
                }
                listView1.Items.Clear();
                bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
            }
            catch { }
        }
    }

    private void 全选ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < listView1.Items.Count; i++)
        {
            listView1.Items[i].Selected = true;
        }
    }

    private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        try
        {
            string pp = listView1.SelectedItems[0].Text;
            bc.GetPath(pp.Trim(), imageList1, listView1, 1);
        }
        catch
        {
            MessageBox.Show("无法打开此文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }

    private void 重命名ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        if (listView1.SelectedItems.Count != 0)
        {
            listView1.SelectedItems[0].BeginEdit();
        }
    }

    private void 删除ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        try
        {
            if (listView1.SelectedItems.Count == 0)
            {
                MessageBox.Show("请选择文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    string path = bc.Mpath() + "\\" + listView1.SelectedItems[i].Text;
                    if (File.GetAttributes(path).CompareTo(FileAttributes.Directory) == 0)
                    {
                        DirectoryInfo dinfo = new DirectoryInfo(path);
                        dinfo.Delete(true);
                    }
                    else
                    {
                        string path1 = bc.Mpath() + "\\" + listView1.SelectedItems[i].Text;
                        FileInfo finfo = new FileInfo(path1);
                        finfo.Delete();
                    }
                }
                listView1.Items.Clear();
                bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
            }
        }
        catch
        { }
    }

    private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
    {
        Application.Exit();
    }

    private void listView1_AfterLabelEdit(object sender, LabelEditEventArgs e)
    {
        try
        {
            string MyPath = bc.Mpath() + "\\" + listView1.SelectedItems[0].Text;
            string newFilename = e.Label;
            string path2 = bc.Mpath() + "\\" + newFilename;
            if (File.Exists(MyPath))
            {
                if (MyPath != path2)
                {
                    File.Move(MyPath, path2);
                }
            }
            if (Directory.Exists(MyPath))
            {
                DirectoryInfo di = new DirectoryInfo(MyPath);
                di.MoveTo(path2);
            }
            listView1.Items.Clear();
            bc.GetListViewItem(bc.Mpath(), imageList1, listView1);
        }
        catch { }
    }
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
        this.tabControl1 = new System.Windows.Forms.TabControl();
        this.tabpage1 = new System.Windows.Forms.TabPage();
        this.toolStrip3 = new System.Windows.Forms.ToolStrip();
        this.toolStripComboBox1 = new System.Windows.Forms.ToolStripComboBox();
        this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
        this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
        this.listView1 = new System.Windows.Forms.ListView();
        this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
        this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
        this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
        this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
        this.imageList1 = new System.Windows.Forms.ImageList(this.components);
        this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
        this.剪切ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.复制ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.粘贴ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
        this.全选ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.打开ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.重命名ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator();
        this.删除ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.退出ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
        this.tabControl1.SuspendLayout();
        this.toolStrip3.SuspendLayout();
        this.contextMenuStrip1.SuspendLayout();
        this.SuspendLayout();
        // 
        // tabControl1
        // 
        this.tabControl1.Controls.Add(this.tabPage1);
        this.tabControl1.Dock = System.Windows.Forms.DockStyle.Top;
        this.tabControl1.HotTrack = true;
        this.tabControl1.Location = new System.Drawing.Point(0, 0);
        this.tabControl1.Multiline = true;
        this.tabControl1.Name = "tabControl1";
        this.tabControl1.SelectedIndex = 0;
        this.tabControl1.Size = new System.Drawing.Size(497, 24);
        this.tabControl1.TabIndex = 1;
        // 
        // tabPage1
        // 
        this.tabPage1.BackColor = System.Drawing.Color.White;
        this.tabPage1.Location = new System.Drawing.Point(4, 21);
        this.tabPage1.Name = "tabPage1";
        this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
        this.tabPage1.Size = new System.Drawing.Size(489, 0);
        this.tabPage1.TabIndex = 0;
        this.tabPage1.Text = "本地驱动器";
        this.tabPage1.UseVisualStyleBackColor = true;
        // 
        // toolStrip3
        // 
        this.toolStrip3.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.toolStripComboBox1,
        this.toolStripSeparator4,
        this.toolStripButton2});
        this.toolStrip3.Location = new System.Drawing.Point(0, 24);
        this.toolStrip3.Name = "toolStrip3";
        this.toolStrip3.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;
        this.toolStrip3.Size = new System.Drawing.Size(497, 25);
        this.toolStrip3.TabIndex = 2;
        this.toolStrip3.Text = "toolStrip3";
        // 
        // toolStripComboBox1
        // 
        this.toolStripComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
        this.toolStripComboBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
        this.toolStripComboBox1.Name = "toolStripComboBox1";
        this.toolStripComboBox1.Size = new System.Drawing.Size(121, 25);
        this.toolStripComboBox1.SelectedIndexChanged += new System.EventHandler(this.toolStripComboBox1_SelectedIndexChanged);
        // 
        // toolStripSeparator4
        // 
        this.toolStripSeparator4.Name = "toolStripSeparator4";
        this.toolStripSeparator4.Size = new System.Drawing.Size(6, 25);
        // 
        // toolStripButton2
        // 
        this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
        this.toolStripButton2.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton2.Image")));
        this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
        this.toolStripButton2.Name = "toolStripButton2";
        this.toolStripButton2.Size = new System.Drawing.Size(23, 22);
        this.toolStripButton2.Text = "toolStripButton2";
        this.toolStripButton2.ToolTipText = "上级文件夹";
        this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
        // 
        // listView1
        // 
        this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.None;
        this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
        this.columnHeader1,
        this.columnHeader2,
        this.columnHeader3,
        this.columnHeader4});
        this.listView1.ContextMenuStrip = this.contextMenuStrip1;
        this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
        this.listView1.FullRowSelect = true;
        this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
        this.listView1.LabelEdit = true;
        this.listView1.Location = new System.Drawing.Point(0, 49);
        this.listView1.Name = "listView1";
        this.listView1.Size = new System.Drawing.Size(497, 252);
        this.listView1.SmallImageList = this.imageList1;
        this.listView1.TabIndex = 3;
        this.listView1.UseCompatibleStateImageBehavior = false;
        this.listView1.View = System.Windows.Forms.View.Details;
        this.listView1.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.listView1_AfterLabelEdit);
        this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
        // 
        // columnHeader1
        // 
        this.columnHeader1.Text = "名称";
        this.columnHeader1.Width = 200;
        // 
        // columnHeader2
        // 
        this.columnHeader2.Text = "大小";
        // 
        // columnHeader3
        // 
        this.columnHeader3.Text = "类型";
        this.columnHeader3.Width = 80;
        // 
        // columnHeader4
        // 
        this.columnHeader4.Text = "更改时间";
        this.columnHeader4.Width = 150;
        // 
        // imageList1
        // 
        this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
        this.imageList1.ImageSize = new System.Drawing.Size(20, 20);
        this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
        // 
        // contextMenuStrip1
        // 
        this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
        this.剪切ToolStripMenuItem,
        this.复制ToolStripMenuItem,
        this.粘贴ToolStripMenuItem,
        this.toolStripSeparator6,
        this.全选ToolStripMenuItem,
        this.打开ToolStripMenuItem,
        this.重命名ToolStripMenuItem,
        this.toolStripSeparator7,
        this.删除ToolStripMenuItem,
        this.退出ToolStripMenuItem});
        this.contextMenuStrip1.Name = "contextMenuStrip1";
        this.contextMenuStrip1.Size = new System.Drawing.Size(107, 192);
        // 
        // 剪切ToolStripMenuItem
        // 
        this.剪切ToolStripMenuItem.Name = "剪切ToolStripMenuItem";
        this.剪切ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.剪切ToolStripMenuItem.Text = "剪切";
        this.剪切ToolStripMenuItem.Click += new System.EventHandler(this.剪切ToolStripMenuItem_Click);
        // 
        // 复制ToolStripMenuItem
        // 
        this.复制ToolStripMenuItem.Name = "复制ToolStripMenuItem";
        this.复制ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.复制ToolStripMenuItem.Text = "复制";
        this.复制ToolStripMenuItem.Click += new System.EventHandler(this.复制ToolStripMenuItem_Click);
        // 
        // 粘贴ToolStripMenuItem
        // 
        this.粘贴ToolStripMenuItem.Name = "粘贴ToolStripMenuItem";
        this.粘贴ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.粘贴ToolStripMenuItem.Text = "粘贴";
        this.粘贴ToolStripMenuItem.Click += new System.EventHandler(this.粘贴ToolStripMenuItem_Click);
        // 
        // toolStripSeparator6
        // 
        this.toolStripSeparator6.Name = "toolStripSeparator6";
        this.toolStripSeparator6.Size = new System.Drawing.Size(149, 6);
        // 
        // 全选ToolStripMenuItem
        // 
        this.全选ToolStripMenuItem.Name = "全选ToolStripMenuItem";
        this.全选ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.全选ToolStripMenuItem.Text = "全选";
        this.全选ToolStripMenuItem.Click += new System.EventHandler(this.全选ToolStripMenuItem_Click);
        // 
        // 打开ToolStripMenuItem
        // 
        this.打开ToolStripMenuItem.Name = "打开ToolStripMenuItem";
        this.打开ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.打开ToolStripMenuItem.Text = "打开";
        this.打开ToolStripMenuItem.Click += new System.EventHandler(this.打开ToolStripMenuItem_Click);
        // 
        // 重命名ToolStripMenuItem
        // 
        this.重命名ToolStripMenuItem.Name = "重命名ToolStripMenuItem";
        this.重命名ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.重命名ToolStripMenuItem.Text = "重命名";
        this.重命名ToolStripMenuItem.Click += new System.EventHandler(this.重命名ToolStripMenuItem_Click);
        // 
        // toolStripSeparator7
        // 
        this.toolStripSeparator7.Name = "toolStripSeparator7";
        this.toolStripSeparator7.Size = new System.Drawing.Size(149, 6);
        // 
        // 删除ToolStripMenuItem
        // 
        this.删除ToolStripMenuItem.Name = "删除ToolStripMenuItem";
        this.删除ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.删除ToolStripMenuItem.Text = "删除";
        this.删除ToolStripMenuItem.Click += new System.EventHandler(this.删除ToolStripMenuItem_Click);
        // 
        // 退出ToolStripMenuItem
        // 
        this.退出ToolStripMenuItem.Name = "退出ToolStripMenuItem";
        this.退出ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
        this.退出ToolStripMenuItem.Text = "退出";
        this.退出ToolStripMenuItem.Click += new System.EventHandler(this.退出ToolStripMenuItem_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(497, 301);
        this.Controls.Add(this.listView1);
        this.Controls.Add(this.toolStrip3);
        this.Controls.Add(this.tabControl1);
        this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
        this.MaximizeBox = false;
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "获取本地磁盘目录";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.tabControl1.ResumeLayout(false);
        this.toolStrip3.ResumeLayout(false);
        this.toolStrip3.PerformLayout();
        this.contextMenuStrip1.ResumeLayout(false);
        this.ResumeLayout(false);
        this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.TabControl tabControl1;
    private System.Windows.Forms.TabPage tabPage1;
    private System.Windows.Forms.ToolStrip toolStrip3;
    private System.Windows.Forms.ToolStripComboBox toolStripComboBox1;
    private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
    private System.Windows.Forms.ToolStripButton toolStripButton2;
    private System.Windows.Forms.ListView listView1;
    private System.Windows.Forms.ColumnHeader columnHeader1;
    private System.Windows.Forms.ColumnHeader columnHeader2;
    private System.Windows.Forms.ColumnHeader columnHeader3;
    private System.Windows.Forms.ColumnHeader columnHeader4;
    private System.Windows.Forms.ImageList imageList1;
    private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
    private System.Windows.Forms.ToolStripMenuItem 剪切ToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem 复制ToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem 粘贴ToolStripMenuItem;
    private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
    private System.Windows.Forms.ToolStripMenuItem 全选ToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem 打开ToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem 重命名ToolStripMenuItem;
    private System.Windows.Forms.ToolStripSeparator toolStripSeparator7;
    private System.Windows.Forms.ToolStripMenuItem 删除ToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem 退出ToolStripMenuItem;
}

到此这篇关于基于C#实现获取本地磁盘目录的文章就介绍到这了,更多相关C#获取本地磁盘目录内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: 基于C#实现获取本地磁盘目录

本文链接: https://www.lsjlt.com/news/175806.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作