博客
关于我
asp.net 4.5 练习~test14-8
阅读量:303 次
发布时间:2019-03-03

本文共 2491 字,大约阅读时间需要 8 分钟。

文件夹管理功能

文件夹管理功能

创建文件夹
删除文件夹

Server-Side Code

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.IO;namespace test14_8{    public partial class WebForm1 : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {            // 页面加载时初始化        }        protected void Button1_Click(object sender, EventArgs e)        {            string path = TextBox1.Text;            if (string.IsNullOrEmpty(path))            {                return;            }            int action = 0;            if (RadioButton1.Checked)            {                action = 1; // 创建文件夹            }            else if (RadioButton2.Checked)            {                action = 2; // 删除文件夹            }            switch (action)            {                case 1:                    if (Directory.Exists(path))                    {                        lblTips.Text = "文件夹已存在!";                        return;                    }                    else                    {                        DirectoryInfo dir = Directory.CreateDirectory(path);                        lblTips.Text = $"创建时间:{dir.CreationTime}
父文件夹:{dir.Parent}"; } break; case 2: try { if (Directory.Exists(path)) { Directory.Delete(path); lblTips.Text = "文件夹已删除!"; } else { lblTips.Text = "文件夹不存在!"; } } catch (Exception ex) { lblTips.Text = ex.Message; } break; default: break; } } }}

转载地址:http://ydrm.baihongyu.com/

你可能感兴趣的文章
Objective-C实现aliquot sum等分求和算法(附完整源码)
查看>>
Objective-C实现all combinations所有组合算法(附完整源码)
查看>>
Objective-C实现all permutations所有排列算法(附完整源码)
查看>>
Objective-C实现all subsequences所有子序列算法(附完整源码)
查看>>
Objective-C实现AlphaNumericalSort字母数字排序算法(附完整源码)
查看>>
Objective-C实现alternate disjoint set不相交集算法(附完整源码)
查看>>
Objective-C实现alternative list arrange备选列表排列算法(附完整源码)
查看>>
Objective-C实现An Armstrong number阿姆斯特朗数算法(附完整源码)
查看>>
Objective-C实现anagrams字谜算法(附完整源码)
查看>>
Objective-C实现ApproximationMonteCarlo蒙特卡洛方法计算pi值算法 (附完整源码)
查看>>
Objective-C实现area under curve曲线下面积算法(附完整源码)
查看>>
Objective-C实现argmax函数功能(附完整源码)
查看>>
Objective-C实现arithmetic算术算法(附完整源码)
查看>>
Objective-C实现armstrong numbers阿姆斯壮数算法(附完整源码)
查看>>
Objective-C实现articulation-points(关键点)(割点)算法(附完整源码)
查看>>
Objective-C实现atoi函数功能(附完整源码)
查看>>
Objective-C实现average absolute deviation平均绝对偏差算法(附完整源码)
查看>>
Objective-C实现average mean平均数算法(附完整源码)
查看>>
Objective-C实现average median平均中位数算法(附完整源码)
查看>>
Objective-C实现average mode平均模式算法(附完整源码)
查看>>