急需解决文件重命名问题
解决问题给分
QQ:280600958

解决方案 »

  1.   

    没有Rename方法.File.Move(a,b)
    就可以把a重命名为b
      

  2.   

    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); 
    }