listview deleting rename
I got a Directory viewer that shows me all logical drives wich maps and wich files it contains. Now i got a questions how do i change mine code so that it also can delete rename and move files/maps.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Eric HamiltonPosted Jan 14, 2010, 5:16 AM
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;
using System.Management;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listView1.View = View.Details;
listView1.Columns.Add("Naam");
listView1.Columns.Add("Groote");
listView1.Columns.Add("Datum laatst gewijzigd");
}
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
{
e.Node.Nodes.Clear();
listView1.Items.Clear();
string[] dir = Directory.GetDirectories(e.Node.FullPath, (@"*"));
for (int i = 0; i < dir.Length; i++)
{
DirectoryInfo mappeninfo = new DirectoryInfo(dir[i]);
e.Node.Nodes.Add(mappeninfo.Name);
}
string[] files = Directory.GetFiles(e.Node.FullPath, ("*"));
ListViewItem item;
FileInfo fi;
for (int i = 0; i < files.Length; i++)
{
item = new ListViewItem(Path.GetFileName(files[i]));
fi = new FileInfo(files[i]);
item.SubItems.Add(fi.Length.ToString());
item.SubItems.Add(fi.LastWriteTime.ToString());
listView1.Items.Add(item);
}
}
private void Form1_Load(object sender, EventArgs e)
{
string[] directories = Directory.GetLogicalDrives();
// hier word de directories geladen
foreach (string s in Directory.GetLogicalDrives())
{
treeView1.Nodes.Add(s);
}
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
string sPath = ("*");
DirectoryInfo di = new DirectoryInfo(sPath);
FileInfo[] rgFiles = di.GetFiles("*");
}
private void afsluitenToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();// Dit sluit de applicatie
}
}
}