我需要大师的帮助才能在浏览器中打开文件。我正在使用以下代码片段从外部CMS获取文件,然后在浏览器中打开它。但它抛出异常:System.IO.FileNotFoundException: Could not find file 'C:\Users\test\Documents\Visual Studio 2010\Projects\connectToABC\DownloadFileFromABCWEB\System.Byte[]'.
代码段
try
{
var searchParams = new ABCLib.ABCSearchParameters();
searchParams.WebServiceURL = serverUrl;
searchParams.MyCredentials = new NetworkCredential("xxxxx", "xxxx");
var contentItems = ABCLib.ABC.SearchABCContent(searchParams);
if ((contentItems != null) && (contentItems.Length > 0))
{
var fileContent = ABCLib.ABCGetFile.GetABCFileContentByName(searchParams.WebServiceURL, searchParams.MyCredentials, "QAABC1000000146789");
string filePath = Server.MapPath(fileContent.ToString());
WebClient user = new WebClient();
Byte[] FileBuffer = user.DownloadData(filePath);
if (FileBuffer != null)
{
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", FileBuffer.Length.ToString());
Response.BinaryWrite(FileBuffer);
}
}
}
catch (Exception)
{
throw;
}