博客
关于我
asp.net 4.5 练习~test14-8
阅读量:304 次
发布时间: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/

你可能感兴趣的文章
POJ1218 HDU1337 ZOJ1350 UVALive2557 THE DRUNK JAILER
查看>>
poj1222 EXTENDED LIGHTS OUT(gauss)
查看>>
POJ1240 m叉树
查看>>
Poj1328--Radar Installation(区间选点)
查看>>
POJ1384Piggy-Bank(DP)
查看>>
POJ1417 True Liars —— 并查集 + DP
查看>>
Poj1459 Power Network 预流推进
查看>>
POJ1502(MPI Maelstrom)
查看>>
poj1568 Find the Winning Move[极大极小搜索+alpha-beta剪枝]
查看>>
poj1730 - Perfect Pth Powers(完全平方数)(水题)
查看>>
poj1753——Flip Game
查看>>
poj1936 假期计划第一水
查看>>
poj1958-汉诺四塔问题(三种方法)
查看>>
poj1988(并查集)
查看>>
POJ2007+几何+极角排序
查看>>
poj2039
查看>>
poj2135(简单的最小费用流问题)
查看>>
poj2195 bfs+最小权匹配
查看>>
POJ2251
查看>>
POJ2253-Frogger
查看>>