954,546 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Opening 20,000 notepad files and appending to one document

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 :)

mariocatch
Junior Poster
103 posts since Apr 2007
Reputation Points: 11
Solved Threads: 17
 

i know that in C# you can use the streamreader function to read text files (part of .net)

please do not post the same thread in two forums by the way

http://www.daniweb.com/techtalkforums/thread77732.html
http://www.daniweb.com/techtalkforums/thread77733.html

jbennet
Moderator
Moderator
18,523 posts since Apr 2005
Reputation Points: 1,826
Solved Threads: 601
 

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.

kmillen
Newbie Poster
6 posts since Apr 2007
Reputation Points: 10
Solved Threads: 0
 

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

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

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.

mariocatch
Junior Poster
103 posts since Apr 2007
Reputation Points: 11
Solved Threads: 17
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You