I am using a RadAsyncUpload control on a page that allows the user to send emails with attachments.
I have in place the work around found here
http://www.telerik.com/community/forums/aspnet-ajax/async-upload/known-issues-and-breaking-changes.aspx
My radscriptmanager is in the master page, here's my radasyncupload declaration
<tel:RadAsyncUpload
ID="fileUpload"
runat="server"
ReadOnlyFileInputs="true"
OnClientValidationFailed="onUploadFailed"
OnClientFileUploadFailed="onUploadFailed"
OnClientFileSelected="onFileSelected"
OnClientFileUploaded="onFileUploaded"
HttpHandlerUrl="~/Handlers/RadAsyncUploadWorkAround.ashx" />
In the code behind,
I have this in my onInit
fileUpload.FileUploaded += new FileUploadedEventHandler(uploaded);
fileUpload.TemporaryFolder = systemDocumentPathRoot;
//fileUpload.TargetFolder = systemDocumentPathFull;
fileUpload.Localization.Select = GetResourceString("Browse");
and for my uploaded method
List<string> fileNames = new List<string>();
public void uploaded(object sender, FileUploadedEventArgs args){
string fileName = @"DocumentFolder" + args.File.FileName;
args.File.SaveAs(fileName);
fileNames.Add(fileName);
}
on my SendButton event
System.Net.Mail.MailMessage message = new MailMessage("Zach.French@blackline.com", "Zach.French@Blackline.com", "test", "this is a test");
foreach(string fileName in fileNames)
message.Attachments.Add(new Attachment(fileName));
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(message);
for a small files it works fine
but when I tried a file at about 2MB or more it fails.
the file is uploaded to the correct temporary location.
When I click the send button and do the full postback, uploaded is called and the file is saved to the correct location
When the send button event is called, an exception is thrown on smtpClient.send(message).
the quick watch of the exception was print screened and is attached as exception.jpg
When I go to the file via the file explorer, and try to delete it I get an error message saying the file is in use (see fileinuse.jpg)
I believe the radasyncupload is still accessing the file or blocking it but I'm not sure.
Any help would be appreciated.