FileStream fs; BinaryWriter bw; int buffersize=100; byte[] outbyte=new byte[buffersize]; long reval; long startIndex; string filePath=""; frame.bin.OracleProc OraProc=new frame.bin.OracleProc(); string sql="select cfile,cname from pro_v_indentcfile where id="+hidMsg.Value; OracleDataReader ord=OraProc.ExecuteReader(sql); if (ord.Read()) { bin.Get_maxid mid=new bin.Get_maxid(); int fileid=0; fileid=mid.getfileid("fileno"); filePath=Server.MapPath(".")+"\\"+"tempDoc"+"\\"+"file"+fileid.ToString()+".doc"; fs=new FileStream(filePath,FileMode.OpenOrCreate,FileAccess.Write); bw=new BinaryWriter(fs); startIndex=0; reval=ord.GetBytes(0,startIndex,outbyte,0,buffersize); while (reval==buffersize) { bw.Write(outbyte); bw.Flush(); startIndex+=buffersize; reval=ord.GetBytes(0,startIndex,outbyte,0,buffersize); } if (reval > 0) bw.Write(outbyte,0,(int)reval-1); bw.Flush(); bw.Close(); fs.Close(); } ord.Close(); OraProc.ConnClose();
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; using System.Configuration; using System.IO; using System.Threading; using Microsoft.Win32; using System.Net;别忘了using
BinaryWriter bw;
int buffersize=100;
byte[] outbyte=new byte[buffersize];
long reval;
long startIndex;
string filePath="";
frame.bin.OracleProc OraProc=new frame.bin.OracleProc();
string sql="select cfile,cname from pro_v_indentcfile where id="+hidMsg.Value;
OracleDataReader ord=OraProc.ExecuteReader(sql);
if (ord.Read())
{
bin.Get_maxid mid=new bin.Get_maxid();
int fileid=0;
fileid=mid.getfileid("fileno");
filePath=Server.MapPath(".")+"\\"+"tempDoc"+"\\"+"file"+fileid.ToString()+".doc";
fs=new FileStream(filePath,FileMode.OpenOrCreate,FileAccess.Write);
bw=new BinaryWriter(fs);
startIndex=0;
reval=ord.GetBytes(0,startIndex,outbyte,0,buffersize);
while (reval==buffersize)
{
bw.Write(outbyte);
bw.Flush();
startIndex+=buffersize;
reval=ord.GetBytes(0,startIndex,outbyte,0,buffersize);
}
if (reval > 0)
bw.Write(outbyte,0,(int)reval-1);
bw.Flush();
bw.Close();
fs.Close();
}
ord.Close();
OraProc.ConnClose();
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
using System.Configuration;
using System.IO;
using System.Threading;
using Microsoft.Win32;
using System.Net;别忘了using
我已经可以将数据写入文件了,但是我还想请问一点,怎样在界面一按读取按钮就能自动打开word文档?