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");
            }
  • 相关阅读:
    SpringSource发布Spring Data Redis 1.0.0
    C#实现的GDI+时钟
    敏捷团队应对打扰的七种方法
    JBoss发布Hibernate 4.0
    在 IE10 的 XHR 的麦子
    Spring AMQP 1.0 GA发布了
    对 64 个以上逻辑处理器使用任务管理器
    预览Visual Studio11: 敏捷的支持、团队协作以及代码克隆监测
    在 Windows 8 中支持传感器
    HTTP API可演进性最佳实践
  • 原文地址:https://www.cnblogs.com/EasonJim/p/5483315.html
Copyright © 2011-2022 走看看