IO Stream Application-small resource manager, io stream Resource Manager

Source: Internet
Author: User

IO Stream Application-small resource manager, io stream Resource Manager

Small Resource Manager

    

 

 

       

 

Private void LoadTreeView ()
{
DirectoryInfo dir = new DirectoryInfo (@ "E :\");
DirectoryInfo [] dirs = dir. GetDirectories ();
Foreach (DirectoryInfo item in dirs)
{
TreeNode tn = new TreeNode ();
Tn. Text = item. Name;
Tn. Tag = item. FullName;
This. treeView1.Nodes. Add (tn );
}

}
Private void Form1_Load (object sender, EventArgs e)
{
LoadTreeView ();

}
Private void BindInfo (TreeNode node)
{
DirectoryInfo dir = new DirectoryInfo (node. Tag. ToString ());
DirectoryInfo [] dirs = dir. GetDirectories ();
Foreach (DirectoryInfo item in dirs)
{
TreeNode tn = new TreeNode ();
Tn. Text = item. Name;
Tn. Tag = item. FullName;
Node. Nodes. Add (tn );
}
FileInfo [] fileInfo = dir. GetFiles ();
List <MyFile> files = new List <MyFile> ();
Foreach (FileInfo item in fileInfo)
{
MyFile file = new MyFile ();
File. FileName = item. Name;
Float value = item. Length;
File. FileLength = float. Parse (Math. Round (value/1024, 2). ToString ());
File. FileType = item. Extension;
File. FilePath = item. FullName;
Files. Add (file );
}
If (this. listView1.Items! = Null)
{
This. listView1.Items. Clear ();
}
Foreach (MyFile item in files)
{
ListViewItem lvItem = new ListViewItem (item. FileName );
LvItem. SubItems. Add (item. FileLength. ToString ());
LvItem. SubItems. Add (item. FileType );
LvItem. SubItems. Add (item. FilePath );
This. listView1.Items. Add (lvItem );
}
}

Private void treeviewappsafterselect (object sender, TreeViewEventArgs e)
{

TreeNode node = this. treeView1.SelectedNode;
BindInfo (node );

}

Private void copy ToolStripMenuItem_Click (object sender, EventArgs e)
{
DialogResult result = folderBrowserDialog1.ShowDialog ();
If (result = DialogResult. OK)
{
String sourcePath = this. listView1.SelectedItems [0]. SubItems [3]. Text;
String desPath = folderBrowserDialog1.SelectedPath;
DesPath + = "\" + this. listView1.SelectedItems [0]. SubItems [0]. Text;
File. Copy (sourcePath, desPath );
MessageBox. Show ("Copied successfully !!! ");
}
}

Private void Delete ToolStripMenuItem_Click (object sender, EventArgs e)
{
String sourcePath = this. listView1.SelectedItems [0]. SubItems [3]. Text;
File. Delete (sourcePath );
MessageBox. Show ("deleted successfully !! ");
TreeNode node = this. treeView1.SelectedNode;
BindInfo (node );
}

 

Related Article

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.