码迷,mamicode.com
首页 > 其他好文 > 详细

Directory类

时间:2014-11-22 15:49:28      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   使用   sp   for   文件   

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 WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("文件夹名称不能为空");
            }
            else
            {
                if (Directory.Exists(textBox1.Text))//使用Directory类的Exists方法判断要创建的文件夹
                {
                    MessageBox.Show("该文件夹已经存在");
                }
                else
                {
                    Directory.CreateDirectory(textBox1.Text);//使用Directory类的CreateDirectory方法创建文件
                }
            }
        }
    }
}

 

Directory类

标签:style   blog   io   ar   color   使用   sp   for   文件   

原文地址:http://www.cnblogs.com/heisaijuzhen/p/4115162.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!