Abhishek Modak
asked on
Recursively finding text files within a specified folder and appending its contents
I want to make a Windows application form that should select a particular folder and then append or overwrite all the text files that are discovered after recursively searching for text files by "hello world" text. All the discovered text files must then contain "hello world" as their content.how to do it in c#?
ASKER
Yup,I mean the the files whose extension is .txt
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
First, I would enumerate the folder and all child objects which are not links or junctions.
Filter this collection by items of whose suffix matches the suffix you're looking for.
Check to see if you have permissions to write to the filtered file objects in the collection.
Use the
Open in new window
where path is the path to the file and append the string in question.