拡張子が*.ico
の画像を表示したいのですが、それにはStream
を使用します。しかし、私には問題があります。ストリームを使用して画像を表示する* .ico
*.jpg
、
*.bmp
... OKイメージ・ショーで
しかし*.ico
、それはここで
は表示されません。私のコードです:
private void OutputStream(string fileName)
{
try
{
Stream dataStream = null;
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPFile spFile = web.GetFile(fileName);
dataStream = spFile.OpenBinaryStream();
this.HandleOutputStream(dataStream);
});
}
catch (System.Threading.ThreadAbortException exTemp)
{
logger.Error("KBStreamPicture::OutputStream", exTemp);
}
catch (Exception ex)
{
//System.Diagnostics.Debug.Write("OutputStream::" + ex);
logger.Error("KBStreamPicture::OutputStream", ex);
}
}
と
private void HandleOutputStream(Stream dataStream)
{
const int bufferSize = 16384; //16KB
using (Stream file = dataStream)
{
if (file != null)
{
this.Page.Response.Clear();
this.Page.Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);
this.Page.Response.Cache.SetExpires(DateTime.Now.AddMinutes(20)); //only cache 20 minutes
byte[] buffer = new byte[bufferSize];
int count = file.Read(buffer, 0, bufferSize);
while (count > 0)
{
if (this.Page.Response.IsClientConnected)
{
this.Page.Response.OutputStream.Write(buffer, 0, count);
count = file.Read(buffer, 0, bufferSize);
}
else
{
count = -1;
}
}
this.Page.Response.End();
}
}
}
に私を助けてくださいその問題を解決してください。
コードは(奇妙なSPセキュリティのオーバーライド、および不明瞭彼らはurlですでにアクセスできる必要があるとき、なぜあなたは手でファイルをダウンストリームしようとすると、OKに見えます... )。サーバ上でファイルのストリームを取得したり、ブラウザでレンダリングする際に問題がありますか(私はICOがIMGタグとしてレンダリングするとは思わない) –