• 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");
            }
  • 相关阅读:
    Windows上DVWA和sqli-labs部署(Debian&Ubuntu)
    easy -heap
    栈迁移基础
    调试下的plt&got
    Linux 下的文件解压
    GitHub的raw.githubusercontent.com无法链接
    ELF文件认知(二)可重定位目标文件
    自动微信聊天
    MinIE: Open Information Extraction system, GROBID, tet-pdf
    MD5 don't know the problem (Solved)
  • 原文地址:https://www.cnblogs.com/EasonJim/p/5483315.html
Copyright © 2020-2023  润新知