| | |
Opening 20,000 notepad files and appending to one document
Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 bitmap box c# c#gridviewcolumn check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime decryption degrees developer draganddrop drawing encryption enum excel file focus form format forms function gdi+ grantorrevokepermissionthroughc#.net hospitalmanagementsystem image input install java list localization mandelbroth marshalbyrefobject math messagebox mouseclick mysql netcfsvcutil.exe numeric operator path photoshop php picturebox pixelinversion platform plotting pointer polynomial post programming properties radians read regex remote remoting richtextbox server sleep socket sql statistics string stringformatting study sun table text textbox thread time timer update usb usercontrol validation visualstudio webbrowser winforms wpf wpfc# xml






