用于浏览文件夹的小程序代码

来源:互联网 发布:对时协议软件 编辑:程序博客网 时间:2024/06/05 18:45

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (folderBrowserDialog1.ShowDialog()==DialogResult.OK)
            {
                textBox1.Text = folderBrowserDialog1.SelectedPath.ToString();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(textBox1.Text=="")
            {MessageBox.Show("您没有选着文件夹");
            return;
            };
            DirectoryInfo dir = new DirectoryInfo(textBox1.Text);
            System.Diagnostics.Process.Start(dir.ToString());
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Clear();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

原创粉丝点击