博客
关于我
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/

你可能感兴趣的文章
Netty源码—4.客户端接入流程一
查看>>
Netty源码—4.客户端接入流程二
查看>>
Netty源码—5.Pipeline和Handler一
查看>>
Netty源码—6.ByteBuf原理二
查看>>
Netty源码—7.ByteBuf原理三
查看>>
Netty源码—7.ByteBuf原理四
查看>>
Netty源码—8.编解码原理二
查看>>
Netty源码解读
查看>>
Netty的Socket编程详解-搭建服务端与客户端并进行数据传输
查看>>
Netty相关
查看>>
Network Dissection:Quantifying Interpretability of Deep Visual Representations(深层视觉表征的量化解释)
查看>>
Network Sniffer and Connection Analyzer
查看>>
NFS共享文件系统搭建
查看>>
ng 指令的自定义、使用
查看>>
nginx + etcd 动态负载均衡实践(二)—— 组件安装
查看>>
Nginx + uWSGI + Flask + Vhost
查看>>
Nginx Location配置总结
查看>>
Nginx 动静分离与负载均衡的实现
查看>>
Nginx 反向代理解决跨域问题
查看>>
Nginx 反向代理配置去除前缀
查看>>