zoukankan      html  css  js  c++  java
  • c# 移动文件或文件夹

    移动文件或文件夹:  

     sourceCode:

                string srcFileName = @"D:\a.txt";
                string destFileName = @"D:\b.txt";

                string srcFolderPath = @"D:\1";
                string destFolderPath = @"D:\6";
               
                //方法一 
                if (System.IO.File.Exists(srcFileName))
                {
                    System.IO.File.Move(srcFileName, destFileName);
                }
                if (System.IO.Directory.Exists(srcFolderPath))
                {
                    System.IO.Directory.Move(srcFolderPath, destFolderPath);
                }
               
                //方法二
                if (System.IO.File.Exists(srcFileName))
                {
                    System.IO.FileInfo file = new System.IO.FileInfo(srcFileName);
                    file.MoveTo(destFileName);
                }
                if (System.IO.Directory.Exists(srcFolderPath))
                {
                    System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(srcFolderPath);
                    folder.MoveTo(destFolderPath);
                }

  • 相关阅读:
    Spring.Net初认识——竹子整理
    SOA:面向服务编程——竹子整理
    unity安装记录
    wcf第三方客户端与wcf服务之间调用入门
    Winform VS2015打包
    OWINS是什么(转载)
    [LR]遇到的坑及常用技巧
    性能测试简单调优
    es6解构赋值
    es6 笔记
  • 原文地址:https://www.cnblogs.com/bison1989/p/1948946.html
Copyright © 2011-2022 走看看