I am starting a new project and i plan to use c# for it. Basically what it entails to is reconfiguring a large am mount of config files. 100+ of them. They are each named differently but are prefixed the same (ex: CONFIG_FILE_xxxxxx , where x changes). Inside the files also follow a similar structure. My question is how would i go about getting started with this. The reconfiguration i plan to do to these files is edit certain parts of the files depending on their name and then saving them. The editing part is going to come from a set amount of fields (ex: ture, false, off, on ..etc) which i plan to hardcode into the program. Open to any suggestions on how about to get started with this. No code please, just suggestions of tools to use.

5 Years
Discussion Span
Last Post by thines01
Featured Replies
  • 1

    Take a look at [URL="http://msdn.microsoft.com/en-us/library/8he88b63.aspx"]DirectoryInfo.GetFiles[/URL], and the [URL="http://msdn.microsoft.com/en-us/library/system.io.file.aspx"]File[/URL] class. Depending on the size of the files you'll want to look at ReadAllLines and WriteAllLines. Read More


He, that's what I had to do very often during my professional IT period some 25 years ago!
Opening a file, read line by line, make changes according to some "rules" found in another file or in a hard coded table, writing the changed line to a new file, until EOF. Repeat until all files are done. Success!


Your code will be the best "tool" for this.
Even if you could find some third-party software to do this: by the time you finish configuring it to work with your files, you could write something to take care of it.

As ddanbe mentioned, so do I: I still do this kind of file manipulation for one reason or other.

Regular expressions (the Regex class) might serve you well.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.