Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
private void Form1_Load(object sender, EventArgs e)
        {
            listfiles.Clear();
            listView1.Items.Clear();
            foreach (string item in Directory.GetDirectories(@"C:\Users\PC\Documents\Visual Studio 2013\Projects\test1\test1\Files\")) {
                FileInfo fi = new FileInfo(item);
                listfiles.Add(fi.FullName);
                listView1.Items.Add(fi.Name, imageList1.Images.Count - 1);
            }
  
        foreach(string item in Directory.GetFiles(@"C:\Users\PC\Documents\Visual Studio 2013\Projects\test1\test1\Files\"))
            {
                imageList1.Images.Add(System.Drawing.Icon.ExtractAssociatedIcon(item));
                FileInfo fi = new FileInfo(item);
                listfiles.Add(fi.FullName);
                listView1.Items.Add(fi.Name, imageList1.Images.Count - 1);  
            
            }
        }

        private void listView1_ItemActivate(object sender, EventArgs e) {
            if (listView1.FocusedItem != null)
                Process.Start(listfiles[listView1.FocusedItem.Index]);
        }


What I have tried:

Hi! I create a file explorer using a listview. How do I add a code that drags and drops a file or folder to listview direct to the path of the folder that I assign? Please Help
Posted
Updated 3-Jul-18 7:06am
v2

1 solution

 
Share this answer
 
Comments
Member 13896947 5-Jul-18 8:02am    
Thank You!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900