What I do is this. My user selects a filename. To download that file hey must press a button-object. In the OnClick Event I Check:
- Does the file Exist via FileInfo
FileInfo fi = new FileInfo(DownLoadFileName); // DownLoadFileName = String containing filename
- FileSize larger then 0
if (fi.Length > 0)
{
arrParameter = new SqlParameter[3];
arrParameter[0] = new SqlParameter("@secUserID", Convert.ToInt32(Session["USERID"]));
arrParameter[1] = new SqlParameter("@reportName", Page.Title);
arrParameter[2] = new SqlParameter("@DownloadedFile", txtExcelFile.Text);
// this line stores the collected data in the sqlparameter via a Stoired Procedure into a database table
SyconosServer.dataBaseActieNonQuery("SE_InsDownload", arrParameter, String.Empty, "SesameNET31");
// Redirect to a common downloadpage so the file is downloadable for the USER
Response.Redirect(@"~/Export/DownLoadFile.aspx", false);
}
In Word you can only store 2 bytes. That is why I use Writer.