这里即时下载GetSourceAttachment方法的word文件。当这个方法返回空字节然后我的字节附件数组给出一个错误(对象引用没有设置对象的实例)。当im检查附件的长度,如果条件那么它给予错误。任何人都可以帮助我默认初始化字节数组,然后检查长度。如何检查字节数组是否为空?
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
{
}
感谢马修·沃特森...... – SANDEEP 2013-05-10 06:21:09