asp.net 4.5 练习~test14-8
发布日期:2021-05-06 21:16:26 浏览次数:12 分类:技术文章

本文共 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; } } }}

 

上一篇:asp.net 4.5 练习~test15-1 xml文件使用xslt转换格式
下一篇:asp.net 4.5 练习~test14-7

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月01日 05时01分52秒