Hey all:

I've been trying to figure out how I would go about doing the following task.

Basically, I have a folder with about 20,000 notepad files. My goal is to have one big word document, and append the contents of each notepad file to the word document. Each notepad file only has about 1 line of text (10-15 words).

I'm not looking for any code on how to do this, just loooking for a pseudo explanation on an approach i could take to tackle this.
Thanks :)

Recommended Answers

All 4 Replies

1. Get all the file names with something like this, where 'parenFolder" is the top directory of the notepad files and extension is "*.txt".

//on exit, "files" will contain the desired list
//assumes parentFolder is valid and not null
private void GetProgramFiles(string parentFolder, ArrayList files, string extension)
{
//if sub folders exist, recurse for each sub folder
foreach(string subDirectory in Directory.GetDirectories(parentFolder))
{
//recurse down
GetProgramFiles(subDirectory, files, extension);
}
//files from current folder
files.AddRange(Directory.GetFiles(parentFolder, extension));
}

2. Iterate through them
3. Write their contents to a doc file.

Member Avatar for iamthwee

There is no need to recurse through any directories. He said he has one folder with all the files immediately there.

was also over a month ago i asked for help on this lol. i figured it out a while ago, and i specifically said in my post i don't want someone to code it for me.

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.