C#.NET - Search, Replace and Update Text Files

I need to write a C#.NET console application that can do the following:

- Read in all text files in a given directory.
- Search each text file in the specified path for a particular text pattern.
- If it does not find the text pattern, it does nothing, and moves on to the next file.
- If it does find the text pattern, it must delete a certain amount of text, stopping at the next place it finds the characters HL*, then update a counter at the bottom of the text file so it shows 7 less than it originally did.

I'm a C#.NET web developer, and know nothing about writing console applications and performing the actions I specified above.  Any help is very appreciated!!

Thanks!
fcsITAsked:
Who is Participating?
 
David L. HansenConnect With a Mentor Programmer AnalystCommented:
Here is one that might get you started.
http://www.dotnetperls.com/file

You can do what you are proposing in C# certainly, however, powershell is built for just this sort of thing.  Would you consider looking down that path?  It would be less code and probably faster in execution as well.  I just bring it up because it sounds like you are going to be going through a learning curve either way.
0
 
David L. HansenProgrammer AnalystCommented:
May I recommend a look through of this tutorial, then start some coding based on that...at that point I/we can help you through with the rest of it.  Sound good?

http://www.withvb.net/tutorials/reading-text-files
0
 
fcsITAuthor Commented:
That's in VB.NET.  I write in C#.NET.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
fcsITAuthor Commented:
Powershell would be fine by me.  I've been wanting to get into that!  :)
0
 
David L. HansenProgrammer AnalystCommented:
Great, good luck with it.  You'll find some great powershell experts here.
0
 
Brent ChallisPrincipal: ITCommented:
Are you interested in a PowerShell solution, or have you already sorted it out?
0
 
fcsITAuthor Commented:
If you have an example I can work from, yes please.  That would save me a ton of time!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.