I'm making a mini disk cleaner and I have wrote this code:

listView1.Items.Clear();

                DirectoryInfo dirCustom = new DirectoryInfo("C:\\Windows\\");

                FileInfo[] filCustom;

                filCustom = dirCustom.GetFiles("*.txt");

                foreach (FileInfo filFile in filCustom)
                {

                listView1.Items.Add(filFile.Name, "test");

                }

However there are some missing parts, works fine but i need to search multiple path and extensions and it only displays the file name on the list view on detailed view. I want it to display the folder path and file size.

Can you add that too my code that is for console app, and it is confusing :S

MSDN example are always for console apps, because it is easy to give a small example.
Nothing prohibits you to use these examples in a Form app.
Line 12 of your code could become: listView1.Items.Add(filFile.FullName, "test");

someone on microsoft helped me i got this code:

listView1.Items.Clear();

                string[] directories = new string[] { "C:\\Windows\\", "c:\\" };
                string[] extensions = new string[] { "*.txt", "*.exe" };

                foreach (var dir in directories)
                {
                    var dirInfo = new DirectoryInfo(dir);
                    foreach (var ext in extensions)
                    {
                        foreach (var fileInfo in dirInfo.GetFiles(ext))
                        {
                            listView1.Items.Add(fileInfo.Name, "test");
                        }
                    }
                }

Only thing left is displaying the folder path and file size.

arent these for console applications, im building a windows form application.

You can use the same methods in a Forms app. But instead of using WriteLine to show info to the user, you can show that info in a MessageBox, a Label, a List or a TextBox etc.

kk i will give that a go, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.