View Single Post
  #1 (permalink)  
Old November 16th, 2008, 05:25 AM
RodrigoGuteriez RodrigoGuteriez is offline
Registered User
Points: 7, Level: 1
Points: 7, Level: 1 Points: 7, Level: 1 Points: 7, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2008
Location: Brentwood, CA, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default read any ".txt" file

Hi,

I am new to C# and trying to read in any .txt file that will be dropped in a directory, I will not have control of the file name.

Here is a sample of my calling code:

class Program
    {
        static void Main(string[] args)
        {
            FlatFileTo850 t = new FlatFileTo850();

            string data = File.ReadAllText("C:\\src\\partner\\ConsoleApplica tion1\\subdir\\testFile.txt");
         //would like to take out the file name "testFile.txt"
         //and grab any .txt file

      string result = t.Evaluate(ref data);

            Console.WriteLine(result);

   using (StreamWriter sw = new StreamWriter("TestFileXX.txt", true))
   {
        sw.Write(result.Replace("~", "~\r\n"));
   }

            Console.ReadLine();
        }
    }

Thanks in advance for any help.

Rod

Reply With Quote