- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用一些屏幕截图代码成功构建了,并且可以进行拖放操作(但没有代码),并且我尝试在文件后在表单上显示一条消息保存成功,或者拖放太多文件。我不想使用 MessageBox.Show
(即使如果我替换代码,此方法也有效),因为我想使用复选标记图片和按钮来打开屏幕截图位置的文件。我的问题是保存屏幕截图后,from#.designer.cs
中的一行崩溃了。我已经到处寻找如何解决这个问题,但没有任何帮助。我不注意触摸 Form3.Designer.cs
文件,因为注释说不要这样做。下面列出了我的代码。
表格 1 中的屏幕截图/屏幕截图代码:
private void saveScreenshotToolStripMenuItem_Click(object sender, EventArgs e)
{
// ** SAVE A SCREENSHOT *** (Working)
Bitmap bitmap = new Bitmap(this.Width, this.Height);
DrawToBitmap(bitmap, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
bitmap.Save((boxFileName.Text) + "_ScreenCap.JPEG",ImageFormat.Jpeg);
// If i replace the following 2 lines with MessageBox.Show("FileSave successful"); it works fine. Why is this code not working????
Form3 f3 = new Form3();
f3.ShowDialog();
}
在 Form3.Designer.CS
中崩溃的代码
// Form3
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 121);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.MaximizeBox = false;
this.MaximumSize = new System.Drawing.Size(300, 150);
this.MinimizeBox = false;
this.MinimumSize = new System.Drawing.Size(300, 150);
this.Name = "Form3";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "ScreenCap Result";
this.Load += new System.EventHandler(this.Form3_Load);
/// the following line crashed
((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();
// end line that crashed
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
这是来自 DragDrop 的代码:
void Form1_DragDrop(object sender, DragEventArgs e)
{
var files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length == 1)
{
/// WORKING
MessageBox.Show("Reading files from Drag and Drop not fully implimentd.");
}
else
{
// NOT WORING (crashes)
Form3 f3 = new Form3();
f3.ShowDialog();
}
任何帮助将不胜感激。
最佳答案
您链接到的屏幕截图上的错误消息显示
InvalidOperationException
Additional information: failed to initialize because the CategoryName is missing.
Microsoft 似乎忘记在 EndInit() 上记录该异常。打电话,但这不是第一个。
因此,在 performanceCounter1
上,我假设其类型为 PerformanceCounter您需要为该属性提供一个值 CategoryName .
您无需手动修改 Form3.Designer.cs
文件即可完成此操作。相反,请在设计器中打开 Form3
,选择 performanceCounter1
并从列表中选择一个值,如以下屏幕截图所示:
关于C# - DisplayDialog() 不适用于 FileSave 和拖/放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45917698/
背景 我正在从事一个基本上可以在客户端生成视频的内部项目,但由于我不知道有任何 JavaScript 视频编码器,所以我只是单独导出每个帧。我需要避免上传到服务器;这一切都发生在客户端。 实现 我正在
我正在使用 FilseSaver.js 保存 rtf 文件。这工作正常。 但是,当我使用特殊字符时,它出错了...字符集自动从 ansi“更改”为 utf-8,并且字符无法正确显示在 rtf 文档中。
我的最终目标是制作一个可以创建 csv 文件的表单。我想弄清楚如何 filesaver.js作品。我尝试了下面的代码但无法使其工作。有什么想法吗?
我正在尝试 FileSaver.js,但是当另存为文本时,所有换行符都消失了。我读过有关 FileSaver.js 的好文章,但丢失了所有换行符,因此它只是一个长文本字符串,这是一个交易破坏者。我总是
我正在开发一个使用 Electron 将 Web 应用程序 package 到桌面应用程序的项目。 在这个项目中,我使用 FileSaver.js 将 Canvas 内容导出为 png/jpg/pdf
我正在使用FileSaver.js使用下面的代码下载文件。该文件会自动下载到默认文件夹(在 Chrome 中测试),但我需要显示一个窗口对话框,其中显示“另存为文件...”之类的内容。谢谢! var
我的问题是,我不断看到一个反复出现的主题,试图让我的记事本克隆保存文件。每当我尝试保存文件时,无论硬盘上的位置如何,都会继续抛出 UnauthorizedAccess 异常。下面是我所做的示例代码,自
我目前正在使用 html2canvas 和 FileSaver,以在单击按钮时保存生成的 Canvas 。将弹出一个对话框,用户可以选择保存图像的位置并根据需要重命名。它在 Firefox 中完美运行
这工作正常,突然停止工作。我不确定到底发生了什么变化。 我需要通过 URL 下载多张图片。 我正在使用以下代码: https://plnkr.co/edit/nsxgwmNYUAVBRaXgDYys?
我在 angular 2 中使用 FileSaver.js,它运行良好;但是,我在构建中遇到语义错误: error TS2304: Cannot find name 'saveAs' 我正在使用 an
我有一个包含以下部分的 Angular 组件: my.component.html(节选) my.component.ts(节选) import {saveAs} from 'file-saver
我在 github 上下载了 FilSaver.js 并尝试对其进行测试以备将来使用。我制作了一个简单的 html 文件,它接受输入,当单击按钮时触发一个函数,该函数将使用 FileSaver 保存文
我在 github 上下载了 FilSaver.js 并尝试对其进行测试以备将来使用。我制作了一个简单的 html 文件,它接受输入,当单击按钮时触发一个函数,该函数将使用 FileSaver 保存文
美好的一天, 我对编程还是新手,我正在使用 FileSaver.js 保存 .txt 文件。 我设法制作了我正在构建的应用程序,将文件保存在我的“下载”文件夹中,但现在当我想读取该文件时却遇到了困难。
我正在使用tkinter用python制作一个小型GUI,其中一部分是询问用户在哪里保存文件。这是我的代码 from tkinter import * import tkinter.filedialo
我不熟悉在 Javascript 中使用导入函数,并且对 how to install filesaver.js. 上的说明感到困惑 在我的代码中,我有: import { saveAs
我正在尝试包括 https://github.com/eligrey/FileSaver.js但是在我的 js 文件中出现以下错误。如果这是正确的做法,我该如何修复 MIME 类型? “拒绝执行来自‘
我正在使用 FileSaver.js文件将我的 Canvas 保存到图像。下载后我必须关闭窗口。有什么办法可以实现吗? 这是我试过的代码, canvas.toBlob(function (blob)
我的前端代码(react)从后端( Node )获取响应并按预期下载 zip 文件,但单击 zip 文件时,将生成 CPGZ 文件,而不是解压缩 zip。 react 代码 downloadResul
我想从 api 下载并保存文件。我的文件名是 text.txt但保存的文件被称为:_text.txt_这个文件的内容是:[object Object] 这是我下载为文件的功能: const optio
我是一名优秀的程序员,十分优秀!