How to approach a problem..

S

SimonH

Hi all,

I'm making a diskspace analyser such that after you select the directory
that you want analysed and hit go, it iterates through all the directories
and files and gather information on them. I'd like to be able to offer lots
of different types of information to the user, including comparitive sizes
of different file types, file type counts, top ten largest directories, empty
files and much more besides.

I'm wondering if anyone could suggest a solution to two different aspects
of this

1. What data structure should I use. This doesnt have to be restricted to
those that come with the .net framework, but whatever is used needs to be
efficient and fast at accessing the information gathered on the different
directories

2. What should I use to gather the statistics that I'll need to be able to
analyse the directories and files. I'm basically thinking that I will need
to make a custom object but I'm worried that this could get really complicated.
Perhaps I would make a directory info object that would contain information
on itself and the directories contained underneath it?

I'm pretty confused about how to gather these statistics and how to analyse
them efficiently

Any advice or design approaches would be very greatfully received

Thank all

Simon
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi,

I'd build custom objects representing a directory, a file, a file collection
and a directory collection.
The file and the directory objects would be able to gather and provide
information about themselves given the physical path.
The collections would be used to store child files and directories.

In the end, there would be an object graph rooted at the directory specified
for analysis and representing the structure beneath this directory (and the
respective information).
I'd also make report classes responsible to generate file type/file size
breakdown reports and other reports you will need. These would use directory
objects as data sources.
 
I

IPGrunt

Hi all,

I'm making a diskspace analyser such that after you select the directory
that you want analysed and hit go, it iterates through all the directories
and files and gather information on them. I'd like to be able to offer lots
of different types of information to the user, including comparitive sizes
of different file types, file type counts, top ten largest directories, empty
files and much more besides.

I'm wondering if anyone could suggest a solution to two different aspects
of this

1. What data structure should I use. This doesnt have to be restricted to
those that come with the .net framework, but whatever is used needs to be
efficient and fast at accessing the information gathered on the different
directories

2. What should I use to gather the statistics that I'll need to be able to
analyse the directories and files. I'm basically thinking that I will need
to make a custom object but I'm worried that this could get really complicated.
Perhaps I would make a directory info object that would contain information
on itself and the directories contained underneath it?

I'm pretty confused about how to gather these statistics and how to analyse
them efficiently

Any advice or design approaches would be very greatfully received

Thank all

Simon

Simon,

IIWY, I'd start at the bottom with the windows file system. You've
got to learn to Interop and call the Windows API--then you don't need
to worry about what the .net interfaces.

There's a new file system coming out with future systems. I'd learn
as much about that as possible and support it. One trick to getting a
new utility app off the mark is to support an emerging technology.

I'm not sure what statistics you're getting at.

-- ipgrunt
 
N

Nick Malik [Microsoft]

Hi Simon,
I'm making a diskspace analyser such that after you select the directory
that you want analysed and hit go, it iterates through all the directories
and files and gather information on them. I'd like to be able to offer
lots of different types of information to the user, including comparitive
sizes of different file types, file type counts, top ten largest
directories, empty files and much more besides.

I'm wondering if anyone could suggest a solution to two different aspects
of this

1. What data structure should I use. This doesnt have to be restricted to
those that come with the .net framework, but whatever is used needs to be
efficient and fast at accessing the information gathered on the different
directories

Personally, I wonder how you are going to collect information on a
heirarchical system with keeping track of the heirarchy itself. Two methods
come to mind: (1) a simple list where each item has associated size, type,
and path information, and where directories contain summary information, and
(2) a tree structure where a directory contains two lists: a list of files
and a list of directories. Files in this structure are different than
directories in that they do not contain files, but may have a type and size,
while directories can only have a size. Both can have security attributes.

To decide which mechanism to offer, it helps to perform a
Commonality-Variability Analysis. This simple analysis technique helps you
to decide what capabilities of your objects to place in different places in
your heirarchy.

My gut tells me that the tree-structure is more likely to produce the
results you need.
2. What should I use to gather the statistics that I'll need to be able to
analyse the directories and files. I'm basically thinking that I will need
to make a custom object but I'm worried that this could get really
complicated. Perhaps I would make a directory info object that would
contain information on itself and the directories contained underneath it?

You are unlikely to get the data collection methods you'd want out of the
basic file and directory objects in .net. I would suggest that you would
want to encapsulate these objects within a wrapper of your own that provides
the statistical methods you desire and which contain the tree members that
you need.


--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top