I wonder if somebody knows how to get real file size (length) of the uploaded file. In my application I use this method:
protected void fileUploaded(object sender, FileUploadedEventArgs e)
{
try
{
if (RadAsyncUpload1.UploadedFiles.Count > 0)
{
if (targetPersonalTmpFolder.Exists.Equals(false)) targetPersonalTmpFolder.Create();
foreach (UploadedFile uploadedFile in RadAsyncUpload1.UploadedFiles)
{
//UploadedFileInfo uploadedFileInfo = new UploadedFileInfo(uploadedFile);
string fullPath = Path.Combine(targetPersonalTmpFolder.ToString(), uploadedFile.GetName());
uploadedFile.SaveAs(fullPath, true);
TmpFiles_List.Add(new UplodedFileData()
{
FileName = uploadedFile.GetName(),
FullFileName = targetPersonalTmpFolder.ToString() + @"\" + uploadedFile.GetName(),
//FileContentLength = Math.Round(uploadedFile.InputStream.Length / 1024d, 0).ToString() + " KB"
FileContentLength = Math.Round(uploadedFile.ContentLength / 1024d, 0).ToString() + " KB"
});
}
BindFiles();
BindTmpFiles();
}
}
catch (Exception ex)
{
//Pravdepodobne bol stlaceny klaves F5 refresh stranky...
ReinitializeForm();
}
}
--------------------------------------------------------------------------------------------
The problem is that property uploadedFile.ContentLength doesn't return real length of the file. I've found that this uploadedFile.InputStream.Length returns correct file size, but when I tried to use it, then this error appeared: The process cannot access the file because it is being used by another process...
Something similar is described here: http://www.telerik.com/community/forums/aspnet-ajax/async-upload/temporary-files-locked-after-upload.aspx
For further information you can check the attachment.
Please help me to solve this issue...
Best regards Vasssek