private void toolStripButtonDelete_Click(object sender, EventArgs e) { ListView.SelectedListViewItemCollection lc = listView1.SelectedItems; if (MessageBox.Show(String.Format("Are you sure you want to delete {0}?", lc.Count == 1 ? string.Format("'{0}'", ((FileInfo)lc[0].Tag).FileName) : "these items"), "vgui", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } foreach (ListViewItem li in lc) { FileInfo fi = (FileInfo)li.Tag; listView1.Items.Remove(li); if (fi.TreeNode != null) { fi.TreeNode.Remove(); } vol.Delete(fi.FullPath); } }
static int Main(string[] args) { switch (args.Length) { case 0: System.Console.WriteLine("usage: vdel image-name file"); return(1); case 1: if (args[0] == "--help") { System.Console.WriteLine("usage: vdel image-name file"); return(0); } System.Console.Error.WriteLine("missing parameter - file"); return(1); case 2: try { FATVolume fatvol = new FATVolume(args[0]); fatvol.Delete(args[1]); fatvol.Close(); } catch (Exception e) { System.Console.Error.Write("error: "); System.Console.Error.WriteLine(e.Message); return(1); } return(0); default: System.Console.Error.WriteLine("too many paramaters"); System.Console.Error.WriteLine("usage: vdel image-name file"); return(1); } }