Hello, I have asked this question before, but didnt get the response I desired, maybe this was due to me being unclear on my intentions, so I shall try again.
I am using the RadUpload control to allow the uploading of image files to my server. After the files a uploaded, they are minipulated server side, height, width etc are adjusted and a watermark is added, so it is very important that I have the correct filename after upload.
When the upload control detects that a file already exists, it fires the following function:
protected void RadUpload1_FileExists(object sender, UploadedFileEventArgs e) |
{ |
int counter = 1; |
UploadedFile file = e.UploadedFile; |
string targetFolder = Server.MapPath(RadUpload1.TargetFolder); |
string targetFileName = Path.Combine(targetFolder, |
file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension()); |
while (System.IO.File.Exists(targetFileName)) |
{ |
counter++; |
targetFileName = Path.Combine(targetFolder, |
file.GetNameWithoutExtension() + counter.ToString() + file.GetExtension()); |
} |
file.SaveAs(targetFileName); |
} |
However my problem is, if I try the followning in my upload button click event:
protected void Button1_Click(object sender, EventArgs e) |
{ |
foreach (UploadedFile f in RadUpload1.UploadedFiles) |
{ |
if (!Object.Equals(f, null)) |
{ |
LooongMethodWhichUpdatesTheProgressContext(f); |
} |
} |
foreach (UploadedFile f in RadUpload1.UploadedFiles) |
{ |
Response.Write(f.GetName() + "<br>"); |
} |
} |