5 Replies - 352 Views - Last Post: 07 March 2012 - 08:19 AM Rate Topic: -----

#1 emreozpalamutcu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-March 12

How to display files in a multiple directory?

Posted 07 March 2012 - 07:07 AM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: How to display files in a multiple directory?

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5469
  • View blog
  • Posts: 11,749
  • Joined: 02-June 10

Re: How to display files in a multiple directory?

Posted 07 March 2012 - 07:40 AM

Quote

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.


You don't have to make announcement about your projects or what you are going to do next. We don't grant permissions or anything.

Quote

works fine


That's great news! Congratulations!

Since there are so many good tutorials on doing a recursive directory listing, and you haven't yet even tried to implement it - I'm not sure what we're supposed to do for you.
Was This Post Helpful? 0
  • +
  • -

#3 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9059
  • View blog
  • Posts: 34,019
  • Joined: 12-June 08

Re: How to display files in a multiple directory?

Posted 07 March 2012 - 07:56 AM

So what are you asking - for someone here to do the work for you? What options have you explored? What have you experimented with?
Was This Post Helpful? 0
  • +
  • -

#4 emreozpalamutcu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-March 12

Re: How to display files in a multiple directory?

Posted 07 March 2012 - 07:59 AM

I solved the problem all i was trying to do was search multiple paths and extesion
Was This Post Helpful? 0
  • +
  • -

#5 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5469
  • View blog
  • Posts: 11,749
  • Joined: 02-June 10

Re: How to display files in a multiple directory?

Posted 07 March 2012 - 08:10 AM

Glad you worked it out. I can subscribe now
Was This Post Helpful? 0
  • +
  • -

#6 emreozpalamutcu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 06-March 12

Re: How to display files in a multiple directory?

Posted 07 March 2012 - 08:19 AM

I can't do one thing, displaying the folder path and file size on list view.

The code I wrote right now is:

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");
                        }
                    }
                }

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1