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?

Amit MohantyRank #112 · 20K reputationPosted Jan 29, 2020, 7:06 PM EST
Amit GuptaRank #190 · 12.8K reputationPosted Jan 30, 2020, 6:02 AM EST
Rajanikant HawaldarRank #110 · 20.2K reputationPosted Jan 29, 2020, 8:20 PM EST
Guest User6 reputationPosted Jan 29, 2020, 8:41 PM EST