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;namespace filestyle{public partial class Form1:form {public Form1 () {InitializeComponent (); } public void Data_list (ListView LV, String F) {string Format = ""; if (F.lastindexof (".") = = f.length-4) Format = f.substring (F.lastindexof (".") + 1, 3); ListViewItem item = new ListViewItem (F); Item. SubItems.Add (Format); Lv. Items.Add (item); private void Listview1_dragenter (object sender, DragEventArgs e) {e.effect = DRAGDROPEFFECTS.C Opy String[] Str_drop = (string[]) e.Data.GetData (DataFormats.FileDrop, true);//must be in string array data_list (ListView1, STR_DR Op[0]); private void Form1_shown (object sender, EventArgs e) { Listview1.gridlines = true; Listview1.view = view.details;//Displays the column name listview1.fullrowselect = true; Listview1.headerstyle = columnheaderstyle.nonclickable;//Hidden column header listView1.Columns.Add ("File name", listview1.width-6 5, HorizontalAlignment.Right); LISTVIEW1.COLUMNS.ADD ("type", "HorizontalAlignment.Center"); } }}
C # File Drag-and-drop to the form of the ListView control get file type