zoukankan      html  css  js  c++  java
  • dotnet文件操作

     /// <summary>
            /// 创建文件夹
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Button1_Click(object sender, EventArgs e)
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
            }
            /// <summary>
            /// 删除文件夹
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Button2_Click(object sender, EventArgs e)
            {
                if (Directory.Exists(path))
                {
                    Directory.Delete(path);
                }
            }
            /// <summary>
            /// 移动文件夹
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Button3_Click(object sender, EventArgs e)
            {
                Directory.Move(path, newpath);
            }
            /// <summary>
            /// 创建文件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Button4_Click(object sender, EventArgs e)
            {
                if (!File.Exists(newpath + @"myfile.txt"))
                {
                    File.CreateText(newpath + @"myfile.txt");
                }
                Response.Write(String.Format("The number of files in {0} is {1}", newpath, Directory.GetFiles(newpath).Length));
            }
            /// <summary>
            /// 删除文件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Button5_Click(object sender, EventArgs e)
            {
                if (File.Exists(newpath + @"myfile.txt"))
                {
                    File.Delete(newpath + @"myfile.txt");
                }
            }
            /// <summary>
            /// 移动文件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            protected void Button6_Click(object sender, EventArgs e)
            {
                File.Move(newpath + @"myfile.txt", path + @"file.txt");
            }
  • 相关阅读:
    算法面试题
    学习进度条(一)
    代码作业——四则运算
    构建之法阅读笔记01
    本学期的阅读计划与快速阅读《构建之法》后提出问题
    自我介绍及学期目标
    对天天开心消消乐(订餐系统)的建议
    《构建之法》阅读笔记01-快速阅读后的几个问题。
    二柱子之随机四则运算
    自我介绍
  • 原文地址:https://www.cnblogs.com/EasonJim/p/5483315.html
Copyright © 2011-2022 走看看