Jerickson - Thursday, October 19, 2006 2:29 PM:
Server side methhod which gets a vaulted file and writes it to a working directory.
I use this to automatically print drawings by moving them to a spool directory.
/*
*/
string
vaultServer = @"">localhost/.../VaultServer.aspx;string
dbName = "Production";string
fileID = this.getProperty("file_id");string
fileName = this.getProperty("file_name");string
workingDir = this.getProperty("working_dir");string
saveAsFileName = workingDir + @"" + fileName;System
.Text.StringBuilder URL = new System.Text.StringBuilder();URL
.Append(vaultServer);URL
.Append("dbName=");URL
.Append(dbName);URL
.Append("&");URL
.Append("fileID=");URL
.Append(fileID);URL
.Append("&");URL
.Append("fileName=");URL
.Append(fileName);HttpWebRequest webRequest
= WebRequest.Create(URL.ToString()) as HttpWebRequest;webRequest
.Method = "GET";HttpWebResponse response
= (HttpWebResponse)webRequest.GetResponse();BinaryReader responseReader
= new BinaryReader(response.GetResponseStream());if
(response.ContentLength > -1){
byte[] buffer = new byte[response.ContentLength];FileStream fs
= new FileStream(saveAsFileName, FileMode.Create);BinaryWriter writer
= new BinaryWriter(fs); long pos=0; int count=1; while (count > 0 && pos < response.ContentLength) {count
= responseReader.Read(buffer, (int)pos, (int)(response.ContentLength - pos));writer
.Write(buffer, (int)pos, count);pos
+= count; }writer
.Close();fs
.Close();}
return
this.newInnovator().newResult(URL.ToString());