该进程无法访问该文件,因为它正被另一个进程使用” Windows 应用程序开发
The process cannot access the file because it is being used by another process” Windows Application Development
我见过类似的问题,但答案对我没有帮助。我正在使用 C# 编写一个基本的 windows 应用程序。这是代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Practice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Main main = new Main();
main.Show();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}
我不知道我做错了什么。
Main 是第二个 window 打开的。
还有其他方法,因为我会误双击。
以下代码解决了我的问题:
private void button2_Click(object sender, EventArgs e)
{
Main main = new Main();
this.Hide();
main.ShowDialog();
this.Close();
}
一些试图提供帮助的人的问题是,由于 this.Hide(),即使我按下关闭 (x) 按钮,程序仍在执行。
但是现在使用上面的代码关闭表单并且在应用程序关闭后没有后台进程运行。
我见过类似的问题,但答案对我没有帮助。我正在使用 C# 编写一个基本的 windows 应用程序。这是代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Practice
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label4_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
this.Hide();
Main main = new Main();
main.Show();
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
}
}
}
我不知道我做错了什么。
Main 是第二个 window 打开的。
还有其他方法,因为我会误双击。
以下代码解决了我的问题:
private void button2_Click(object sender, EventArgs e)
{
Main main = new Main();
this.Hide();
main.ShowDialog();
this.Close();
}
一些试图提供帮助的人的问题是,由于 this.Hide(),即使我按下关闭 (x) 按钮,程序仍在执行。
但是现在使用上面的代码关闭表单并且在应用程序关闭后没有后台进程运行。