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

你可能感兴趣的文章
java编程常见类型题 --- 面向对象编程、程序逻辑(金字塔)、多线程同步
查看>>
【MapReduce】基础案例 ---- 自定义OutputFormat <根据内容输出到指定文件目录中>
查看>>
【Android】 模拟器上运行程序报错
查看>>
计算机网络ip知识点
查看>>
react(3)——导入了正确的包,但是运行不出来,原因是因为导入包的顺序有问题
查看>>
react(10)——三大属性state,props,refs,总结其特点
查看>>
mybatis(11)——在mybatis中配置并使用log4j日志
查看>>
Java 对象流
查看>>
7-39 魔法优惠券
查看>>
南京晓庄学院-数据库系统概论期末复习习题册(1)数据库系统概述
查看>>
南京晓庄学院-数据库系统概论期末复习习题册(4)数据库安全性
查看>>
fufu学前端之H5+Javascript
查看>>
web学习(三)
查看>>
Mybatis进阶
查看>>
对用户ID、组ID、附属组ID、有效、实际、设置用户、设置组ID等的理解
查看>>
协议分层
查看>>
利用JavaCV实现将视频以帧方式抽取
查看>>
ListView 与 RecyclerView 简单对比
查看>>
Marvell 98DX51xx / 98DX81xx 系列交换芯片 内部初始化
查看>>
初次使用 Supervisor 管理 Laravel 队列进程
查看>>