我创造了一个按钮。在按钮的事件处理程序中,我要删除文件夹(abc)中的所有文件。
以下是此代码:
private void button1_Click_1(object sender, EventArgs e)
{
MessageBox.Show("Are you sure!!!! The files in the folder will be deleted permanently");
this.Close();
string[] filePaths = Directory.GetFiles(@"C:\
我有这段代码,我打开一个流(没有关闭或处理它),然后我复制流使用的文件,我认为我应该得到一个“进程无法访问文件somefile.xml,因为它正被另一个进程使用”异常,但我没有。你知道为什么吗?谢谢!代码:
StreamWriter writer = new StreamWriter("C:\\somefile.xml");
writer.Write(string.Empty);
// I thought this should crash since a stream is using "C:\somefile.xml"
File.Copy("C:
有相当奇怪的情况。有两个应用程序:
1) C:\MyFolder1\First.exe
2) C:\MyFolder2\Second.exe
First.exe运行Second.exe并退出。
Process.Start(@"C:\MyFolder2\Second.exe");
// And exit.
Seconds.exe等待了几秒钟,并尝试删除"C:\MyFolder1\“文件夹。
// Wait for 5 seconds - First.exe terminated by that time for 100%
Directory.Delete(@"
我正在自定义msbuild任务中运行一个外部进程。这个任务在程序集A中,当我构建项目B时调用它。一切正常。但是,在尝试清理项目时。Visual Studio2008给我一个错误,说“该进程无法访问程序集A,因为它正被另一个进程使用”。重新启动Visual Studio可以解决此问题。
调用外部进程的代码如下
Process process = new Process();
process.StartInfo = new ProcessStartInfo
{
FileName = @"c:\program.exe",
Arguments = "",