views:

57

answers:

3

I am working on a search and replace console app to help out some people in my department. I am trying to have them input a file path and also the type of file they would like to search for. if they want to find txt files then it will find all txt files in a directory...stick these into an array and then process the files as needed. I am able to do the search and replace part.

I am new to C# and have a solution working in Python, but they want it more portable.

+3  A: 
string path = @"C:\temp";
string searchPattern = "*.txt";
string[] files = Directory.GetFiles(path, searchPattern);
foreach (string f in files)
    Console.WriteLine(f);
RedFilter
A: 

You could always port it to IronPython if they are worried about .Net compatibility.

Josh
It is more of an exercise to help me learn C#...since it is part of my job and all. But I do appreciate the answer...
Woundedbear
A: 

This question is really too broad, we aren't going to write the code for you.

However, here are some links to functionality common in this type of app:

Listing Files in a Directory:

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=356

Reading and Writing Files:

http://www.csharp-station.com/HowTo/ReadWriteTextFile.aspx

Hope that is a good enough head start.

David
For some reason I was hitting a wall...just needed a push and wasn't expecting anyone to write my code, I appreciate the answer not the insinuation.
Woundedbear