473,387 Members | 1,529 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Reading Directory Information

Hi, all.

I have been asked to write an application that would keep track on archive
data on CDs and DVDs. I will basically need a line for each file.

I have started out by saving a "dir" to a text file and parsing the file,
but it seems there must be a better way to do this.

Is there a way to read down a directory tree and get all the folder and file
information?
Any help is greatly appreciated.
Nov 17 '05 #1
2 1426

Użytkownik "Greg Smith" <gj*@umn.edu> napisał w wiadomości
news:%2****************@tk2msftngp13.phx.gbl...
Hi, all.

I have been asked to write an application that would keep track on archive
data on CDs and DVDs. I will basically need a line for each file.

I have started out by saving a "dir" to a text file and parsing the file,
but it seems there must be a better way to do this.

Is there a way to read down a directory tree and get all the folder and
file information?

If you want to scan disk recursive, you can use that code:
---
public void ProcessDir(string sourceDir, int recursionLvl)
{
string [] fileEntries = Directory.GetFiles(sourceDir);
foreach(string fileName in fileEntries)
fileList.Items.Add (fileName ,CheckState.Checked);

string [] subdirEntries = Directory.GetDirectories(sourceDir);
foreach(string subdir in subdirEntries)
if ((File.GetAttributes(subdir) &
FileAttributes.ReparsePoint)!=FileAttributes.Repar sePoint)
ProcessDir(subdir,recursionLvl+1);
}
---
this works with checkbox list, but of course you can change it, and save to
xml or sth.
Inez Korczyński
Nov 17 '05 #2
Exactly what I needed.

Thanks a million.

"Inez Korczynski" <ko*************@gazeta.pl> wrote in message
news:da**********@inews.gazeta.pl...

Użytkownik "Greg Smith" <gj*@umn.edu> napisał w wiadomości
news:%2****************@tk2msftngp13.phx.gbl...
Hi, all.

I have been asked to write an application that would keep track on
archive data on CDs and DVDs. I will basically need a line for each
file.

I have started out by saving a "dir" to a text file and parsing the file,
but it seems there must be a better way to do this.

Is there a way to read down a directory tree and get all the folder and
file information?

If you want to scan disk recursive, you can use that code:
---
public void ProcessDir(string sourceDir, int recursionLvl)
{
string [] fileEntries = Directory.GetFiles(sourceDir);
foreach(string fileName in fileEntries)
fileList.Items.Add (fileName ,CheckState.Checked);

string [] subdirEntries = Directory.GetDirectories(sourceDir);
foreach(string subdir in subdirEntries)
if ((File.GetAttributes(subdir) &
FileAttributes.ReparsePoint)!=FileAttributes.Repar sePoint)
ProcessDir(subdir,recursionLvl+1);
}
---
this works with checkbox list, but of course you can change it, and save
to xml or sth.
Inez Korczyński

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Joel Goldstick | last post by:
I wanted to write a simple page to let me choose a directory and then list the files in it. The end goal was to make an easy way to copy all the file names in a directory. I tested with Opera7,...
1
by: Mark | last post by:
Hello all! I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt). I have the...
7
by: Daniel Moree | last post by:
I'm working on a program that must first establish if the file exists in the program directory then it must open if for reading, read each line and set the variables then the program goes on about...
1
by: Microsoft | last post by:
I have a c# asp.net application. The application has many directories full of images, and each directory has a web.config file containing information about the images in that directory. I'd like...
2
by: Mark | last post by:
Hello all! I've created an ASP.NET project using Visual Studio 2003 and C#. The project is quite basic in that it simply needs to read in the contents of a text file (.txt). I have the...
0
by: tmsprowl | last post by:
Greetings! I was wondering if someone could help me with a problem I'm having. My department is just one of many within my organization. My organization has control over the network domain,...
4
by: Utahduck | last post by:
I do a lot of file processing and I usually run a little script I copy and paste to read directory information to see if a new file it there and then process the file if it is. So, I decided to...
21
by: Naya | last post by:
Hello, everyone!!! Well, I have a situation here. I am trying to read this data from a file, but the wrong values keep spitting out at me. Here's what I mean: Program: int main() {...
4
by: Laharl | last post by:
My Operating Systems professor has assigned homework that basically boils down to implementing ls -lra, but with a different output format. In other words, list the files and subdirectories (and a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.