Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. LINQ;
Using system. text;
Using system. Windows. forms;
Using system. IO;
Namespace templatefiledelete
{
Public partial class deletefiles: Form
{
Int I = 0;
Public deletefiles ()
{
Initializecomponent ();
}
Private void btopen_click (Object sender, eventargs E)
{
Dealaction (sender, e );
}
Private void btopen2_click (Object sender, eventargs E)
{
Dealaction (sender, e );
}
Public void dealaction (Object sender, eventargs E)
{
Fbdshow. showdialog ();
Button bt = (button) (sender );
If (Bt. Name = "btopen ")
{
This. tbpath1.text = fbdshow. selectedpath;
}
Else if (Bt. Name = "btopen2 ")
{
This. tbpath2.text = fbdshow. selectedpath;
}
}
Public void dirs (string path)
{
Directoryinfo Dis = new directoryinfo (PATH );
Fileinfo [] files = dis. getfiles ();
Foreach (fileinfo fi in files)
{
I ++;
Application. doevents ();
This. label1.text = I. tostring ();
Try
{
File. Delete (Fi. fullname );
}
Catch (exception ex)
{
This. richtextbox1.text + = ex. message;
}
// Getsqlfile (Fi. fullname, this. textbox1.text + fi. directoryname. substring (2), Fi. fullname. substring (Fi. fullname. lastindexof ("\") + 1, 1024,768 );
}
If (DIS. getdirectories (). length> 0)
{
For (INT I = 0; I <dis. getdirectories (). length; I ++)
{
Dirs (DIS. getdirectories () [I]. fullname );
}
}
}
Private void btdelete_click (Object sender, eventargs E)
{
Dirs (this. tbpath1.text. Trim ());
Dirs (this. tbpath2.text. Trim ());
}
}
}