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 );
}