将字节[]转换为流文件asp.net
我需要将Byte()转换为流,然后刷新 它在asp.net应用中的应用 这是我的密码:将字节[]转换为流文件asp.net,asp.net,vb.net,model-view-controller,Asp.net,Vb.net,Model View Controller,我需要将Byte()转换为流,然后刷新 它在asp.net应用中的应用 这是我的密码: Dim fileBytes As Byte() = Nothing .... apiProp.BodyRequest = New JavaScriptSerializer().Serialize(entFile) apiProp.EndPoint = "example.com/DownloadFile" apiProp = api.MessageInvoke(apiProp) ent
Dim fileBytes As Byte() = Nothing
....
apiProp.BodyRequest = New JavaScriptSerializer().Serialize(entFile)
apiProp.EndPoint = "example.com/DownloadFile"
apiProp = api.MessageInvoke(apiProp)
entResponse = JsonConvert.DeserializeObject(Of FileResponse)(apiProp.BodyResponse)
fileBytes = Convert.FromBase64String(entFile.fileContent)
我试过:
Response.BinaryWrite(fileBytes)
Response.Flush()
我尝试过任何filestream、memorystream等。文件要求下载,但如果我下载文件,文件就会损坏
我需要将文件转换为流,因为我必须在图像文件上添加水印。我正在使用groupdocs.watermark添加水印。这是否回答了您的问题?否,因为我需要处理文件以添加水印,我使用groupdocs.watermark添加水印,库需要stream/file path(string)参数,但我将文件保存在服务器中的base64 string上。所以我不能得到文件路径(或者我不知道如果我的文件被转换成base64字符串如何得到文件路径),答案是C。问题是VB.NET。
using (Stream InputStream = fl.PostedFile.InputStream)
{
Object o = new object();
lock (o)
{
byte[] buffer = new byte[InputStream.Length];
InputStream.Read(buffer, 0, (int)InputStream.Length);
lock (o)
{
File.WriteAllBytes(rpath, buffer);
buffer = null;
}
InputStream.Close();
}
}