private void button1_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileFullName = openFileDialog1.FileName; //string fileName = Path.GetFileName(fileFullName); string extension = Path.GetExtension(fileFullName); string dateNow = DateTime.Now.ToString("yyyyMMddHHmm"); string destFileName = dateNow + extension; using (FileStream fs = new FileStream(fileFullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); Wopi_Proxy.UploadFile_GetLink(destFileName, data, new Action <string>((link) => { if (!string.IsNullOrEmpty(link)) { this.webBrowser1.Navigate(link); } //Wopi_Proxy.Delete_File(destFileName, new Action<bool>((isSuccessed) => // { // if(isSuccessed) // { // } // })); })); } } }
private void Wopi_Proxy1(HttpContext context) { string result = ""; string filePath = context.Server.MapPath(context.Request["filepath"]); string fileFullName = Path.GetFileName(filePath); string extension = Path.GetExtension(fileFullName); string dateNow = DateTime.Now.ToString("yyyyMMddHHmmss"); string destFileName = dateNow + extension; using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { byte[] data = new byte[fs.Length]; fs.Read(data, 0, data.Length); Wopi_Proxy.UploadFile_GetLink(destFileName, data, new Action <string>((link) => { result = link; })); } context.Response.Write(result); context.Response.End(); }