void SaveFiles(out XElement Attachments)
{
Attachments = null;
if (Uploader1.UploadedFiles.Count() > 0)
{
Attachments = new XElement("files");
foreach (var file in Uploader1.UploadedFiles)
{
string ext = System.IO.Path.GetExtension(file.FileName).ToLower();
string FileName = System.IO.Path.GetFileNameWithoutExtension(file.FileName) + "_" + Guid.NewGuid().ToString().Substring(0, 4) + ext;
Attachments.Add(new XElement("file", FileName));
file.SaveAs(AppDomain.CurrentDomain.BaseDirectory + "upload\\support\\" + FileName);
}
}
}
And markup
<dx:ASPxUploadControl ID="Uploader1" runat="server" Width="280px">
<AdvancedModeSettings EnableMultiSelect="True" />
</dx:ASPxUploadControl>
regardless i choose multiple files or even nothing at all here count is alway 1.
is it correct way to get files by UploadedFiles?
It is necessary to handle the ASPxUploadControl.FileUploadComplete event and retrieve the posted file(s) via the event’s arguments.
Take a look at this demo to see this functionality in action.