Solved

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

Posted on 2012-03-26
7
548 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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:bchallis
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video discusses moving either the default database or any database to a new volume.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now