Guest User

Guest User

  • Tech Writer
  • 8
  • 144

Delete files through a button.

Jan 30 2020 12:39 AM
Hello I need some help with deleting files .txt through a button with windows forms. Because when I try to do this, I'm getting this error when trying to delete.
Error is:  file is being used in a process..... etc. So I can't delete the file.
Code is very simple: File.Delete(textBox1.Text);
Watched an tutorial and followed it, but it wont let me delete the files.
 
And I have this code too: 
 
if(dlg.ShowDialog() == DialogResult.OK) {
StreamReader reader = new StreamReader(dlg.FileName, Encoding.Default);
textBox1.Text = dlg.FileName;
}
 
if this will help.  
 
 
Could anyone help me?
 

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (4)