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

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

webform1.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test14_8.WebForm1" %>

请输入文件夹名称

webform1.aspx.cs

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 (path == string.Empty) return;            int action = 0;            if (RadioButton1.Checked)            {                action = 1; // 创建             }            if (RadioButton2.Checked)            {                action = 2; //删除            }            switch (action)            {                 case 1:                    if (Directory.Exists(path))                    {                        lblTips.Text = "文件夹已存在!";                        return;                    }                    else                    {                        DirectoryInfo dr = Directory.CreateDirectory(path);                        lblTips.Text = "";                        lblTips.Text += "创建时间:" + dr.CreationTime + "
"; lblTips.Text += "父文件夹:" + dr.Parent + "
"; } break; case 2: if (Directory.Exists(path)) { try { Directory.Delete(path); lblTips.Text = ""; lblTips.Text = "文件夹已删除!"; } catch (Exception ex) { lblTips.Text = ex.Message; } } else { lblTips.Text = "文件夹不存在!"; } break; default: return; break; } } }}

 

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

你可能感兴趣的文章
mysql union orderby 无效
查看>>
mysql where中如何判断不为空
查看>>
mysql workbench6.3.5_MySQL Workbench
查看>>
MySQL Workbench安装教程以及菜单汉化
查看>>
MySQL Xtrabackup 安装、备份、恢复
查看>>
mysql [Err] 1436 - Thread stack overrun: 129464 bytes used of a 286720 byte stack, and 160000 bytes
查看>>
MySQL _ MySQL常用操作
查看>>
MySQL – 导出数据成csv
查看>>
MySQL —— 在CentOS9下安装MySQL
查看>>
mysql 不区分大小写
查看>>
mysql 两列互转
查看>>
MySQL 中开启二进制日志(Binlog)
查看>>
MySQL 中文问题
查看>>
MySQL 中日志的面试题总结
查看>>
mysql 中的all,5分钟了解MySQL5.7中union all用法的黑科技
查看>>
Mysql 中的日期时间字符串查询
查看>>
MySQL 中锁的面试题总结
查看>>
MySQL 中随机抽样:order by rand limit 的替代方案
查看>>
MySQL 为什么需要两阶段提交?
查看>>
mysql 为某个字段的值加前缀、去掉前缀
查看>>