2016-05-05 67 views

回答

0

你可以尝试这样的事:

try { 
    String filePath = @"yourfolder\Filename.docx"; 
    String newfilePath = @"yourNweFolder\NewFileName" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".docx"; 
    File.Copy(filePath, newfilePath, false); 
} catch(Exception ex) { 
    //Do stuff 
} 

或者使用下面的代码来获取文件路径

String fileName = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath 
        + "YourNewFolderName", "YourNewFileName" 
        + DateTime.Now.ToString("yyyyMMddHHmmss") + ".doc"); 
+0

谢谢配合!我做了类似的工作: string sourceFile = Server.MapPath(“Templates/mytemplate.docx”); string destFile = Server.MapPath(“NewDocuments/NovoDocumento_”+ title +“.docx”); System.IO.File.Copy(sourceFile,destFile,true); –

相关问题