Fast and easy way to output directory tree to excel.

NJDubois

Well-known member
Joined
May 15, 2008
Messages
84
Programming Experience
Beginner
I'm looking for a way to output a directory tree in some sort of format that I can paste it into an excel spreadsheet and send it to a client.

I have been up and down google, found many code snippets and applications that promise to do this but don't actually deliver what I need. I found one that came close to what I need, but didn't output it the way I needed it.

I need the final excel spreadsheet tree to look like it would look if you were viewing the tree in a directory tree similar to my computer.

For example:

VB.NET:
C:\
      \Folder 1
            \Sub Folder 1
            \Sub Folder 2
      \Folder 2
            \Sub Folder 1
                  \Another Folder
      \Folder 3


The one program I found that got close outputted the tree like this:
C:\
\Folder 1
\Folder 2
\Folder 3

c:\Folder 1\
\Sub Folder 1
\Sub Folder 2

c:\Folder 2\
\Sub Folder 1

c:\Folder 2\Sub Folder 1\
\Another Folder

And so on...

This is really close, but is going to be a huge pain to work this output to be in the format I need.

any suggestions? While I believe I am capable of writing an application to do this, I feel I am re inventing the wheel doing so.

Thanks for reading this, I don't know if this is the right forum for this question, I'm trying to get my question in front of other developers cause I'm sure you have had this problem before.

Really, thanks!

Nick
 
Hi,

any suggestions? While I believe I am capable of writing an application to do this, I feel I am re inventing the wheel doing so.

I am not aware of any existing control that is going to do this for you so you are going to have to design something.

I would suggest that you use a Recursive routine to iterate through your Directory structure and build any formatting you need into a string representation of the current Directory name. i.e, indent the string with a Tab character if its a child of a parent directory. Then just output the string to either a file or a multiline TextBox and then copy and paste to Excel.

Hope that helps.

Cheers,

Ian
 
Back
Top