This is a migrated thread and some comments may be shown as answers.
Getting Uploaded Filename(s)
1 Answer 69 Views
This is a migrated thread and some comments may be shown as answers.
Mick
Top achievements
Rank 1
Mick asked on 10 Jun 2008, 07:37 PM
Hi All,

When using the radupload control, if the file exists I modify the filename as such:

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);

}



My question is, that .GetName() still returns the original filename and not the modified name, so how can I access the (collection of) original name(s)?

Do I manually have to manage the save event myself? If so are there any examples of doing this?

Kind Regards

1 Answer, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 13 Jun 2008, 11:43 AM
Hi Mick,

I'm afraid I could not understand your question properly. The GetName() method of the UploadedFile class returns exactly the original name of the file being uploaded. As the code is being executed in the body of the FileExists event handler, that means that there is already a file with the specified name in the target folder.

If you need to have the new names, you can create a string collection, where you can store the modified file names.

Let me know if I am missing something.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Asked by
Mick
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
Share this question
or