如何在上传时重命名文件

时间:2015-11-23 05:22:36

标签: c#

我正在上传文件。所以我想更改我的文件名。

 string createfolder = "E:/tmp/jobres/" + uId;
 System.IO.Directory.CreateDirectory(createfolder);
 string newfilename = txtname.Text + "Resume" + fileExtension;
 AsyncFileUpload1.SaveAs(Path.Combine(createfolder,newfilename ));

此时间文件采用不同的格式,而不是替换。

1 个答案:

答案 0 :(得分:0)

string createfolder = "E:/tmp/jobres/" + uId;

System.IO.Directory.CreateDirectory(createfolder);

//AsyncFileUpload1.SaveAs(Path.Combine(createfolder,"Give Something Here whatever is changing at all time like time value"+AsyncFileUpload1.PostedFile.FileName));

AsyncFileUpload1.SaveAs(Path.Combine(createfolder,"DateTime.Now"+AsyncFileUpload1.PostedFile.FileName));