I am working in a project,I have used the RadUpload,the code of upload file in my project is follow:
First,I upload a file "test.txt" into server, then I upload the file "test.txt" second times, in server it's name is renamed as "test1.txt",this project works well, but when I upload the file "test.txt" third times , the RadProgressArea's Elapsed time and Speed run all the time, the radupload can not upload this file, I try this action several times ,but can not work well too.
I think my code where rename the upload file can not work well,but it seems that my code is correct.
What can I do in this situation?
Are there any settings about RadUpload to solve my question?
Thanks
Hu Tao
protected void Submit_Click(object sender, EventArgs e) |
{ |
if (RadUpload1.UploadedFiles.Count > 0) |
{ |
System.Threading.Thread.Sleep(3000); |
try |
{ |
string targetFolder = Server.MapPath(@"UpLoadFile\Project"); |
string targetFileName = string.Empty; |
foreach (UploadedFile files in RadUpload1.UploadedFiles) |
{ |
int counter = 1; |
string fileName = files.GetName(); |
string fileName1 = files.GetNameWithoutExtension() + counter.ToString() + files.GetExtension(); |
targetFileName = System.IO.Path.Combine(targetFolder, fileName); |
while (System.IO.File.Exists(targetFileName)) |
{ |
targetFileName = System.IO.Path.Combine(targetFolder, fileName1); |
fileName = fileName1; |
counter++; |
} |
files.SaveAs(targetFileName); |
//here,I insert the file info into DB; |
} |
} |
catch (Exception ex) |
{ |
throw ex; |
} |
} |
} |
First,I upload a file "test.txt" into server, then I upload the file "test.txt" second times, in server it's name is renamed as "test1.txt",this project works well, but when I upload the file "test.txt" third times , the RadProgressArea's Elapsed time and Speed run all the time, the radupload can not upload this file, I try this action several times ,but can not work well too.
I think my code where rename the upload file can not work well,but it seems that my code is correct.
What can I do in this situation?
Are there any settings about RadUpload to solve my question?
Thanks
Hu Tao