hi
Im facing here some dilema , I am using the radupload control to push some files to the server , they will be dropped in some folder i defined in the control with TargetFolder , i have subscribed the FileExists event handler to check if some file with the same name exists on target everything is fine till here, the thing is that when a file is renamed to not overwrite another in the destination folder i cannot update its new name on the radupload control let me explain
i need this because later i loop through uploaded files , and do some more processing on them ... i can think on several ways to go arround this but isnt conceptually wrong not beeing able to update the filename ???
thanks for your time , and i hope im not missing something obvious
Im facing here some dilema , I am using the radupload control to push some files to the server , they will be dropped in some folder i defined in the control with TargetFolder , i have subscribed the FileExists event handler to check if some file with the same name exists on target everything is fine till here, the thing is that when a file is renamed to not overwrite another in the destination folder i cannot update its new name on the radupload control let me explain
void
RadUpload1_FileExists(
object
sender, Telerik.Web.UI.Upload.UploadedFileEventArgs e)
{
int
counter = 1;
UploadedFile file = e.UploadedFile;
string
targetFolder = Server.MapPath(
this
.RadUpload1.TargetFolder);
string
targetFileName = System.IO.Path.Combine(targetFolder,
file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension());
while
(System.IO.File.Exists(targetFileName))
{
counter++;
targetFileName = System.IO.Path.Combine(targetFolder,
file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension());
}
file.SaveAs(targetFileName);
file.FileName = System.IO.Path.GetFileName(targetFileName);
// <---- this line here
}
i need this because later i loop through uploaded files , and do some more processing on them ... i can think on several ways to go arround this but isnt conceptually wrong not beeing able to update the filename ???
thanks for your time , and i hope im not missing something obvious