如何将(.doc/.docx/.pdf/.txt)文件转换为字节数组,反之亦然(在Windows中) [英] how to convert a (.doc/.docx/.pdf/.txt) file to byte array and vice versa.(In windows)

查看:100
本文介绍了如何将(.doc/.docx/.pdf/.txt)文件转换为字节数组,反之亦然(在Windows中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多数据,其中一些在(.doc/.docx/.pdf/.txt)中.我想将这些文件的数据以字节数组的形式保存到sql表中,当我将需要它,然后再次将它们从字节数组转换为我想要的(.doc/.docx/.pdf/.txt).
所以基本上我想帮助他们将它们转换为字节数组,然后从字节数组转换为(.doc/.docx/etc ..).(Windows不在asp.net或vb.net中)

解决方案

文件到字节数组

 字节 [] ByteArray = File.ReadAllBytes(" <文件路径>"); 


字节数组到文件

 // 别忘了写文件扩展名
File.WriteAllBytes(" ,ByteArray); 


i have many data,some of them are in (.doc/.docx/.pdf/.txt).I want to save the data of these files into sql table in the form of byte array,and when I will need it,then again want to convert them from byte array to (.doc/.docx/.pdf/.txt) for as i want.
So basically i want help to convert them to byte array and from byte array to (.doc/.docx/etc..).(Windows not in asp.net or vb.net)

解决方案

File to Byte Array

Byte[] ByteArray= File.ReadAllBytes("<file path>");


Byte Array to File

//Do not forget to write the file extension
File.WriteAllBytes("<file path>",ByteArray);


这篇关于如何将(.doc/.docx/.pdf/.txt)文件转换为字节数组,反之亦然(在Windows中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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