メソッドのwordファイルをダウンロードしていますGetSourceAttachment
。このメソッドが空のバイトを返すと、バイトAttachment
配列でエラーが発生します。
オブジェクト参照がオブジェクトのインスタンスを設定していません
状態の長さを確認するとエラーになりAttachment
ますif
。
バイト配列をデフォルトで初期化し、長さを確認するのを手伝ってくれる人はいますか?
try
{
byte[] Attachment = null ;
string Extension = string.Empty;
ClsPortalManager objPortalManager = new ClsPortalManager();
Attachment = objPortalManager.GetSourceAttachment(Convert.ToInt32(hdnSourceId.Value), out Extension);
if (Attachment.Length > 0 && Attachment != null)
{
DownloadAttachment("Attacment", Attachment, Extension);
}
else
{
ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "<script type='text/javascript'>alert('Attachment is not Uploaded !');</script>");
}
}
catch
{
}