zoukankan      html  css  js  c++  java
  • asp.net如何更改文件名!

     
    把c:\aa.txt
    改名成   c:\bb.txt

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

    string   srcFolderPath=@ "c:\temp ";
    string   destFolderPath=@ "c:\temp11 ";
    //方法一  
    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);  
    }

  • 相关阅读:
    with异常
    内建函数的重写
    布尔测试函数重写
    函数重写
    类中的对象属性管理函数
    类中的迭代器__iter__
    多继承
    多态
    封装
    深入理解Java:类加载机制及反射
  • 原文地址:https://www.cnblogs.com/12go/p/2137808.html
Copyright © 2011-2022 走看看