我尝试过以下方法:
private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if ((Keys) e.KeyValue == Keys.Escape)
this.Close();
}
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
然后我尝试了这个:
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.KeyCode == Keys.Escape)
this.Close();
}
Run Code Online (Sandbox Code Playgroud)
仍然没有任何工作.
我的Windows窗体表单属性上的KeyPreview设置为true ...我做错了什么?
我有一个包含大量文件夹,子文件夹和所有文件的目录.我的项目的想法是递归整个目录,收集文件的所有名称并替换无效字符(对于SharePoint迁移无效).
但是,我对正则表达式完全不熟悉.我需要在文件名中摆脱的字符是: ~, #, %, &, *, { } , \, /, :, <>, ?, -, |
和""
我想用一个空格来代替这些字符.我希望使用一种string.replace()
方法来查看所有这些文件名并进行替换.
到目前为止,我得到的唯一代码是递归.我正在考虑递归扫描驱动器,获取这些文件的名称并将它们放入List<string>
.
任何人都可以帮助我如何使用RegEx查找/替换无效字符与这些特定字符?
有没有人知道如何使用C#和Excel Interop以编程方式打印excel文件?如果是这样,你能提供代码吗?
我正在尝试从我的C#代码中打印一个word文档.我使用了12.0.0.0 Word Interop,我正在尝试做的是在文档打印之前弹出打印对话框.我不是100%肯定所有这些的语法,因为我无法让我的代码工作:(任何想法?
提前致谢!
我有以下代码:
using System;
using System.Diagnostics;
using System.IO;
using PdfSharp.Pdf.Printing;
namespace PrintPdfFile
{
class Program
{
[STAThread]
static void Main(string[] args)
{
// Set Acrobat Reader EXE, e.g.:
PdfFilePrinter.AdobeReaderPath = @"C:\\Documents and Settings\\mike.smith\\Desktop\\Adobe Reader 9.0.exe";
// -or-
//PdfPrinter.AdobeReaderPath = @"C:\Program Files\Adobe\[...]\AcroRd32.exe";
//// Ony my computer (running a German version of Windows XP) it is here:
//PdfFilePrinter.AdobeReaderPath = @"C:\\Documents and Settings\\mike.smith\\Desktop\\Adobe Reader 9.0.exe";
// Set the file to print and the Windows name of the printer.
// At my home office I …
Run Code Online (Sandbox Code Playgroud) 如果我有以下内容:
MyString.ValueType = typeof(System.Decimal);
Run Code Online (Sandbox Code Playgroud)
我怎么能用逗号输出小数?换句话说,我不想看到1234.5,而是希望看到1,234.5
有谁知道这个的语法?我一直在寻找各处,我能找到的就是C++代码.我正在尝试使用System.IO.Packaging命名空间以编程方式密码保护excel文件.
有任何想法吗?
补充说明:
我不使用Excel互操作 - 而是使用System.IO.Packaging命名空间来加密和密码保护excel文件.
我是Crystal Reports的新手,并且有兴趣了解哪些书最有用.我打算使用Designer以及将Crystal Reports与.NET C#应用程序集成.
任何人都知道哪个是最适合这个目的的书?
我对RegEx很新 - 所以有人可以帮我弄清楚到底出了什么问题吗?
我有这个代码:
string regPattern = "*[~#%&*{}/<>?|\"-]+*";
string replacement = "";
Regex regExPattern = new Regex(regPattern);
Run Code Online (Sandbox Code Playgroud)
然而,当我的应用程序遇到regExPattern行时,我得到一个ArgumentException - Quantifier {x,y}后面没有任何错误.
有人可以帮忙吗?
编辑:我需要将此模式传递到foreach循环,如下所示:
if (paths.Contains(regPattern))
{
foreach (string files2 in paths)
{
try
{
string filenameOnly = Path.GetFileName(files2);
string pathOnly = Path.GetDirectoryName(files2);
string sanitizedFileName = regExPattern.Replace(filenameOnly, replacement);
string sanitized = Path.Combine(pathOnly, sanitizedFileName);
//write to streamwriter
System.IO.File.Move(files2, sanitized);
}
catch (Exception ex)
{
//write to streamwriter
}
}
}
else
{
//write to streamwriter
}
Run Code Online (Sandbox Code Playgroud)
如果将模式传递到此循环中,如何定义模式?
我需要在Crystal Reports上创建一个数据透视表.现在我正在使用ODBC连接......但是虽然我知道你可以在CR中创建一个数据透视表,但我并不是百分之百确定如何做到这一点.这里的任何人都知道这是一个简单的逐步方法吗?