private void OnDownloadTempCommand() { String FileUrl = CustomUri.GetAbsoluteUrl("ProductmanagerFileTemp/重要部件到货信息导入模版.xls"); try { saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "All Files|*.*"; saveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(saveFileDialog, new object[] { "重要部件到货信息导入模版.xls" }); bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult != true) { return; } WebClient client = new WebClient(); Uri uri = new Uri(FileUrl, UriKind.RelativeOrAbsolute); client.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted); client.OpenReadAsync(uri); } catch (System.Exception ex) { NotifyWindow notifyWindow = new NotifyWindow("下载错误", ex.Message); notifyWindow.Show(); } }
private void SaveFileTolocal() { if (SelectedTempFileEntity == null) { return; } m_SaveFileDialog = new SaveFileDialog(); m_SaveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(m_SaveFileDialog, new object[] { SelectedTempFileEntity.DefaultFileName }); bool?saveResult = m_SaveFileDialog.ShowDialog(); if (saveResult == null) { return; } if (saveResult == false) { return; } string appstr = System.Windows.Application.Current.Host.Source.AbsoluteUri; WebClient client = new WebClient(); Uri uri = new Uri(getAbsPath(SelectedTempFileEntity.FileServerPath), UriKind.RelativeOrAbsolute); client.OpenReadCompleted += client_OpenReadCompleted; client.OpenReadAsync(uri); }
private void OnDownloadCommand() { saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "All Files|*.*"; saveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(saveFileDialog, new object[] { this.FileName }); bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult != true) { return; } WebClient client = new WebClient(); Uri uri = new Uri(FileUrl, UriKind.RelativeOrAbsolute); client.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged); client.OpenReadAsync(uri); DownLoading = Visibility.Visible; }
private void onOpenDownloadTempFile() { TempSaveFileDialog = new SaveFileDialog(); TempSaveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(TempSaveFileDialog, new object[] { "建安申请表模板.xls" }); bool?saveResult = TempSaveFileDialog.ShowDialog(); if (saveResult.HasValue) { if (saveResult.Value == true) { string appstr = System.Windows.Application.Current.Host.Source.AbsoluteUri; WebClient client = new WebClient(); Uri uri = new Uri(getAbsPath("TempFiles/申报表_模板.xls"), UriKind.RelativeOrAbsolute); client.OpenReadCompleted += client_OpenReadCompleted; client.OpenReadAsync(uri); } } }
private void OnDownloadCommand() { //MessageBox.Show(FileUrl); if (FileUrl == null) { string manufactureNumberTemp = manufactureNumber.TrimEnd(); string rmanufactureNumberTemp = ""; if (!String.IsNullOrEmpty(rmanufactureNumber)) { rmanufactureNumberTemp = rmanufactureNumber.TrimEnd(); } FileUrl = (CustomUri.GetAbsoluteUrl(String.IsNullOrEmpty(rmanufactureNumber) ? manufactureNumberTemp : rmanufactureNumberTemp) + "/" + fileName); //FileUrl = (CustomUri.GetAbsoluteUrl(String.IsNullOrEmpty(rmanufactureNumber) ? manufactureNumber.TrimEnd() : rmanufactureNumber.TrimEnd()) + "/" + fileName); } //MessageBox.Show(FileUrl); try { saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "All Files|*.*"; saveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(saveFileDialog, new object[] { this.FileName }); //MessageBox.Show("3"); bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult != true) { return; } //MessageBox.Show("4"); WebClient client = new WebClient(); Uri uri = new Uri(FileUrl, UriKind.RelativeOrAbsolute); client.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged); client.OpenReadAsync(uri); DownLoading = Visibility.Visible; } catch (System.Exception ex) { //MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
private void onDownload() { if (fileUrl == null) { if (TaxPayerIsLink.GetValueOrDefault(false)) { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerLinkId.Value) + "/" + TaxPayerDocumentName); } else { fileUrl = (CustomUri.GetAbsoluteUrl("upload/" + TaxPayerId.Value) + "/" + TaxPayerDocumentName); } } try { saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "All Files|*.*"; saveFileDialog.GetType().GetMethod("set_DefaultFileName").Invoke(saveFileDialog, new object[] { TaxPayerDocumentName }); bool?dialogResult = saveFileDialog.ShowDialog(); if (dialogResult != true) { return; } WebClient client = new WebClient(); Uri uri = new Uri(fileUrl, UriKind.RelativeOrAbsolute); client.OpenReadCompleted += new OpenReadCompletedEventHandler(OpenReadCompleted); client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressChanged); client.OpenReadAsync(uri); DownLoading = Visibility.Visible; } catch (System.Exception ex) { MessageBox.Show(ex.StackTrace); } }