判断文件是否正在使用

实现效果:

  

知识运用:

  File类的move方法  判断是否可以移动

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            radioButton2.Checked = true;
            openFileDialog1.ShowDialog();
            try
            {
                File.Move(openFileDialog1.FileName,"C:\\C.EXE");
            }
            catch (Exception ex)
            {
                radioButton1.Checked = true;    
            }
        }

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10226491.html