java word转二进制_word内容 二进制相互转换(CSDN 下载)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class Default2 : System.Web.UI.Page
{
Default2 dr;
protected void Page_Load(object sender, EventArgs e)
{
dr = new Default2();
string path = Server.MapPath(@"新文件夹1\ww.doc");
dr.ConvertWord(dr.wordConvertByte(path));
}
private byte[] wordConvertByte(string wordPath)
{
byte[] bytContent = null;
FileStream fs = null;
BinaryReader br = null;
try
{
fs = new FileStream(wordPath, System.IO.FileMode.Open);
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
br = new BinaryReader((Stream)fs);
bytContent = br.ReadBytes((Int32)fs.Length);
br.Close();
fs.Close();
return bytContent;
}
protected void ConvertWord(byte[] data)
{
string filepath = Server.MapPath(@"新文件夹1\mr.doc");
FileStream fs = new FileStream(filepath, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(data, 0, data.Length);
bw.Close();
fs.Close();
}
}
更多推荐



所有评论(0)