Delete image functions unrelated to databases

Source: Internet
Author: User

zj123.sqldb. dbaccess DBA = new zj123.sqldb. dbaccess (this. textbox2.text. trim ();
// insert temporary table data --
string tempinsertsql = "insert into tempdatafiles ([filename]) of the corresponding year and month select [filename] From datafiles where [filename] Like '% "+ this. textbox1.text. trim () + "% '";
string tempdeletesql = "delete from tempdatafiles";
DBA. getstate (tempdeletesql + ";" + tempinsertsql + ";");
stringbuilder sbsql = new stringbuilder ("delete from drivefiles;");
system. io. directoryinfo dir = new system. io. directoryinfo (this. folderbrowserdialog1.selectedpath);

foreach (system. io. fileinfo fi in Dir. getfiles ()
{< br> sbsql. appendformat ("insert into drivefiles ([filename], [filepath]) values ('{0}', '{1}');", Fi. name, Fi. fullname);

}
Foreach (system. Io. directoryinfo di in Dir. getdirectories ())
{
Foreach (system. Io. fileinfo fi in Di. getfiles ())
{
Sbsql. appendformat ("insert into drivefiles ([filename], [filepath]) values ('{0}', '{1}');", Fi. name, Fi. fullname );

}

}
DBA. getstate (sbsql. tostring ());
String tempdeletsql = "select * From drivefiles where [filename] Not in (select [filename] From tempdatafiles )";
Datatable dt = DBA. gettable (tempdeletsql );
Int I = 0;
Int A = DT. Rows. count;
Foreach (datarow DR in DT. Rows)
{
System. Io. file. Delete (convert. tostring (Dr ["filepath"]). Trim ());
I ++;
This. label4.text = "deleting" + I. tostring () + "--- total" + A. tostring (). tostring ();
Application. doevents ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.