C # Resource Manager

Source: Internet
Author: User

Private void button2_click (Object sender, eventargs E)
{
Dirdg (treeview1.nodes. Add (@ "F:/my projects", "My Projects "));
}
// All directory files obtained as nodes
Void dirdg (treenode Tn)
{
Try
{
Foreach (string STR in directory. getdirectories (TN. Name ))
{
Dirdg (TN. nodes. Add (STR, path. getfilenamewithoutextension (STR )));
}
}
Catch
{}

}

Private void button3_click (Object sender, eventargs E)
{
Listview1.items. Clear ();
// Retrieve the file under the traversal node and add it to listviewitem.
Foreach (string STR in directory. getdirectories

(Treeview1.selectednode. Name ))
{
Listviewitem LVI = listview1.items. Add (STR,

Path. getfilenamewithoutextension (STR), 0 );
// Obtain a list of details
LVI. subitems. Add (directory. getlastwritetime (STR). tostring ("yyyy Year mm

Dd "));
LVI. subitems. Add ("folder ");
LVI. subitems. Add (getsize (STR). tostring ());

}
// Obtain all objects
Foreach (string STR in directory. getfiles (treeview1.selectednode. Name ))
{
Listviewitem LVI = listview1.items. Add (STR, path. getfilename (STR ),

0 );
LVI. subitems. Add (file. getlastwritetime (STR). tostring ("YYYY mm dd

"));
LVI. subitems. Add (path. getextension (STR ));
LVI. subitems. Add (New fileinfo (STR). length. tostring ());

}

}
// Obtain the file size
Long getsize (string path)
{
Long Len = 0;
Foreach (string STR in directory. getdirectories (PATH ))
{
Len = getsize (STR );
}
Long Len = 0;
Foreach (string STR in directory. getfiles (PATH ))
{
Fileinfo Fi = new fileinfo (STR );
Len + = Fi. length;
}
Return Len + Len;
}

Private void combobox#selectedindexchanged (Object sender, eventargs E)
{
Listview1.view = (View) enum. parse (typeof (view ),

Combobox1.selecteditem. tostring ());
}

Private void form1_load (Object sender, eventargs E)
{
Combobox1.datasource = enum. getnames (typeof (View ));
}

Private void listview1_click (Object sender, eventargs E)
{

}

Private void listview1_doubleclick (Object sender, eventargs E)
{
String Path = listview1.selecteditems [0]. Name;
If (! Path. hasextension (PATH ))
{
Listview1.items. Clear ();
Foreach (string STR in directory. getdirectories (PATH ))
{
Listviewitem LVI = listview1.items. Add (STR,

Path. getfilenamewithoutextension (STR), 0 );
LVI. subitems. Add (directory. getlastwritetime (STR). tostring ("yyyy

MM dd "));
LVI. subitems. Add ("folder ");
LVI. subitems. Add (getsize (STR). tostring ());
}
}
Else
{// Directly open the file with the extension
Process. Start (PATH );
}
}

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.