我正在创建一个文件,它的Visual C# application部分功能是在.gz文件出现在目录中时提取文件。.gz一旦执行命令行参数,该文件就会出现在指定的目录中。
不幸的是,我收到一条错误消息,说“找不到此文件”,这是由于它读取行以.gz过快地提取文件的原因。
换句话说,它试图.gz在命令行参数执行之前执行文件并将文件实际放入目录中。
我想找到一种方法让我的程序在继续读取下一行之前等待文件出现在目录中。
以下是我的代码,任何帮助将不胜感激!谢谢!
else if (ddlDateType.Text == "Monthly" || ddlDateType.Text == "")
{
//Check if Monthly date entered is valid
if (DateTime.TryParseExact(txtDate.Text, MonthlyFormat, null,
System.Globalization.DateTimeStyles.None, out Test) != true)
{
MessageBox.Show("Enter a valid date.\nFormat: yyyyMM");
}
else
{
//Method that executes an arugment into the command prompt
ExecuteCommand();
//Method that extracts the file after it has already appeared in the directory
ExtractFile();
/*
Goal is to …Run Code Online (Sandbox Code Playgroud) 我使用此代码使我的所有文本框都相同的字体:
if (textBox1.Font.Underline)
{
foreach (Control y in this.Controls)
{
if (y is TextBox)
{
((TextBox)(y)).Font = new Font(((TextBox)(y)).Font, FontStyle.Regular);
}
}
}
else
{
foreach (Control y in this.Controls)
{
if (y is TextBox)
{
((TextBox)(y)).Font = new Font(((TextBox)(y)).Font, FontStyle.Underline);
}
}
Run Code Online (Sandbox Code Playgroud)
让我说我点击粗体按钮.该文将变为粗体.当我点击下划线按钮时,文字应该是粗体和下划线,但它只有下划线??? 为什么?
我在帖子之前搜索了一些东西,但我找不到这样的东西.基本上,我想从文本框中获取文本,保存为变量(比如history1),然后能够在将来调用它来显示文本.我可以这样做,但我坚持的是我想要3个变量(例如history1,history2和history3),每次按下按钮时,字符串都会移动到下一个变量.
例如,按下按钮,文本将保存为变量history1.文本被更改并再次按下按钮,history1中的文本被移动到变量history2,新文本被保存为history1.这只需要工作3个实例,而不是无限制,所以当文本存储在history3中并按下按钮时,文本就会被覆盖.
我想到接近这个的方式是:
string history1;
string history2;
string history3;
for (int i = 1; i < 4; i++)
{
history1 = txtOutput.Text;
btnToFile_Click()
{
history2=history1;
btnToFile_Click()
{
history3=history2;
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,这不会起作用,因为btnToFile_Click不会采取任何争论.是否有更简单的方法来解决这个问题,或者只是一种方法来修复不采用争论的方法?
提前致谢!
如果已经提出这个问题,我道歉.另外,请耐心等待我,因为我是C#的新手并且刚开始学习它.我正在尝试编写一个简单的程序(hello world)来学习,但是当我编译程序时,我得到一个错误.下面是我尝试构建解决方案后的屏幕截图.我将不胜感激任何帮助.