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

你可能感兴趣的文章
NMF(非负矩阵分解)
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>
NO.23 ZenTaoPHP目录结构
查看>>
NO32 网络层次及OSI7层模型--TCP三次握手四次断开--子网划分
查看>>
NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
查看>>
Node JS: < 一> 初识Node JS
查看>>