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);
}
}
}
和标记
<dx:ASPxUploadControl ID="Uploader1" runat="server" Width="280px">
<AdvancedModeSettings EnableMultiSelect="True" />
</dx:ASPxUploadControl>
无论我选择多个文件,甚至这里什么都没有,计数总是 1。 通过 UploadedFiles 获取文件是否正确?