二进制格式的文档 [英] document with binary format

查看:90
本文介绍了二进制格式的文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,我已经从共享点文档库中下载了我的文档.
当我查看我的文档时,它是二进制格式.如何转换为普通格式.
我在这里附上了我的代码:


here, I have downloading my document from share point document library.
when i view my document it is in binary format. how to convert to normal format.
here i have attached my code:


byte[] binfile = item.File.OpenBinary();
               FileStream fstream = new FileStream(@"E:\Oliver\" + item.File.Name, FileMode.Create, FileAccess.ReadWrite);
               //fstream.Write(binfile, 0, binfile.Length);
               if (Response.IsClientConnected)
               {

                   int length = fstream.Read(binfile, 0, binfile.Length);
                   Response.OutputStream.Write(binfile, 0, binfile.Length);
                   Response.Flush();
               }

               fstream.Close();

推荐答案

我认为您需要以常规文件格式显示二进制数组.

I think You need to display the binary array in normal file format.

private void ShowDocument(string fileName, byte[] fileContent)
        {
            //Split the string by character . to get file extension type
            string[] stringParts = fileName.Split(new char[] { '.' });
            string strType = stringParts[1];
            Response.Clear();
            Response.ClearContent();
            Response.ClearHeaders();
            Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
            //Set the content type as file extension type
            Response.ContentType = strType;
            //Write the file content
            this.Response.BinaryWrite(fileContent);
            this.Response.End();
        }



查看我的文章.

http://www.c -sharpcorner.com/UploadFile/1a81c5/convert-file-to-byte-array-and-byte-array-to-files/ [



Check my article.

http://www.c-sharpcorner.com/UploadFile/1a81c5/convert-file-to-byte-array-and-byte-array-to-files/[^]


这篇关于二进制格式的文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆