本文介绍了流到Base64String - 内存不足异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
帮助您解决此问题,在源下面抛出System.OutOfMemory异常在线
返回Convert.ToBase64String(stream.ToArray());
private static string GetSPFileBinary(ClientContext ctx,string fileUrlPath) { ctx.RequestTimeout = Int32.MaxValue; var spFile = ctx.Web.GetFileByServerRelativeUrl(fileUrlPath); var spFileContent = spFile.OpenBinaryStream(); ctx.Load(spFile); ctx.ExecuteQuery(); MemoryStream stream = new MemoryStream(); if(spFileContent!= null&& spFileContent.Value!= null) { spFileContent.Value.CopyTo(stream); } 返回Convert.ToBase64String(stream.ToArray()); }谢谢
解决方案检查是否有效:
返回Convert.ToBase64String(stream.GetBuffer(),stream.Length);
文件有多大?
Help appreciated in resolving this issue, below source throws System.OutOfMemory exception at line
return Convert.ToBase64String(stream.ToArray());
private static string GetSPFileBinary(ClientContext ctx, string fileUrlPath) { ctx.RequestTimeout = Int32.MaxValue; var spFile = ctx.Web.GetFileByServerRelativeUrl(fileUrlPath); var spFileContent = spFile.OpenBinaryStream(); ctx.Load(spFile); ctx.ExecuteQuery(); MemoryStream stream = new MemoryStream(); if (spFileContent != null && spFileContent.Value != null) { spFileContent.Value.CopyTo(stream); } return Convert.ToBase64String(stream.ToArray()); }Thanks
解决方案Check if this works:
return Convert.ToBase64String( stream.GetBuffer(), stream.Length);
How large is the file?
更多推荐
流到Base64String
发布评论