Please review the follow sample code to save the open Microsoft Office file in the EDraw Office Viewer Component to the remote server with the ASP code.

SaveDoc1.asp

<%@LANGUAGE=”VBSCRIPT” CODEPAGE=”936″%>
 <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
 <html>
 <head>
 <meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
 <title>EDraw Office Viewer Component</title>
 </head>
 
 <body>
 <%readonly int enterCount = 12;
 string[] requestValues = new string[3];
 string newFile = Server.MapPath(“.”)+”\\Document\\” + DateTime.Now.ToFileTime().ToString() + “NewDoc.doc”;
 
 BinaryReader br = new BinaryReader(Request.InputStream);
 
 
 br.BaseStream.Seek(0,SeekOrigin.Begin);
 
 int enterNo = 0;
 int streamHeadLen = 0;
 while(br.BaseStream.Position < br.BaseStream.Length) {
 streamHeadLen ++;
 char c = (char)br.ReadByte();
 if(enterNo < enterCount){
 if(c == ‘\n’){
 enterNo ++;
 }
 }
 else{
 break;
 }
 }
 br.BaseStream.Seek(0,SeekOrigin.Begin);
 string strTemp = System.Text.UTF8Encoding.Default.GetString(br.ReadBytes(streamHeadLen – 1));
 
 string str =””;
 int index=0;
 string[] requestStrings = {“RecordID”,”UserID”};
 for(int i=0;i<requestStrings.Length;i++)
 {
 str = “Content-Disposition: form-data; name=\””+requestStrings[i]+”\”\r\n\r\n”;
 index = strTemp.IndexOf(str) + str.Length;
 if( index != str.Length – 1)
 {
 for(int j=index;j<strTemp.Length;j++)
 {
 if(strTemp[j] != ‘\r’)
 this.requestValues[i] += strTemp[j];
 else
 break;
 }
 }
 }
 str = “; filename=\”;
 index = strTemp.IndexOf(str) + str.Length;
 if( index != str.Length – 1)
 {
 for(int j=index;j<strTemp.Length;j++)
 {
 if(strTemp[j] != ‘\r’)
 this.requestValues[2] += strTemp[j];
 else
 break;
 }
 }
 
 FileStream newDoc = new FileStream(newFile,FileMode.Create,FileAccess.Write);
 BinaryWriter bw = new BinaryWriter(newDoc);
 bw.BaseStream.Seek(0,SeekOrigin.End);
 while(br.BaseStream.Position < br.BaseStream.Length – 38)
 {
 bw.Write(br.ReadByte());
 }
 br.Close();
 bw.Flush();
 bw.Close();
 
 %>
 </body>
 </html>