Solved

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

Posted on 2012-03-26
7
555 Views
Last Modified: 2012-03-27
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!
0
Comment
Question by:fcsIT
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 37767007
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
 

Author Comment

by:fcsIT
ID: 37767581
That's in VB.NET.  I write in C#.NET.
0
 
LVL 15

Accepted Solution

by:
David L. Hansen earned 500 total points
ID: 37768151
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:fcsIT
ID: 37768164
Powershell would be fine by me.  I've been wanting to get into that!  :)
0
 
LVL 15

Expert Comment

by:David L. Hansen
ID: 37768292
Great, good luck with it.  You'll find some great powershell experts here.
0
 
LVL 8

Expert Comment

by:Brent Challis
ID: 37769241
Are you interested in a PowerShell solution, or have you already sorted it out?
0
 

Author Comment

by:fcsIT
ID: 37771745
If you have an example I can work from, yes please.  That would save me a ton of time!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question