| | |
Opening 20,000 notepad files and appending to one document
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2007
Posts: 103
Reputation:
Solved Threads: 17
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
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
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
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
If i am helpful, please give me reputation points.
•
•
Join Date: Apr 2007
Posts: 6
Reputation:
Solved Threads: 0
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.
//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.
![]() |
Similar Threads
- Front Page error when opening .HTM file (HTML and CSS)
- Opening 20,000 notepad files and appending to one document (C)
Other Threads in the C# Forum
- Previous Thread: Select Right Tab
- Next Thread: open exe file using c#
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication concurrency control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






