C# Reading Paths From Text File Says Path Doesn't Exist : <p>I'm developing a small command line utility to remove files from a directory. The user has the option to specify a path at the command line or have the paths being read from a text file.</p>

<p>Here is a sample text input:</p>

<pre><code>C:\Users\MrRobot\Desktop\Delete
C:\Users\MrRobot\Desktop\Erase
C:\Users\MrRobot\Desktop\Test
</code></pre>

<p>My Code:</p>

<pre><code>class Program
    {
        public static void Main(string[] args)
        {

            Console.WriteLine("Number of command line parameters = {0}", args.Length);

            if(args[0] == "-tpath:"){

                    clearPath(args[1]);
            }
            else
                if(args[0] == "-treadtxt:"){

                    readFromText(args[1]);
                }

        }

        public static void clearPath(string path)
        {
            if(Directory.Exists(path)){

                int directoryCount = Directory.GetDirectories(path).Length;

                if(directoryCount &gt; 0){

                    DirectoryInfo di = new DirectoryInfo(path);

                    foreach (DirectoryInfo dir in di.GetDirectories())
                    {
                        dir.Delete(true); 
                    }

                }
                else{

                    Console.WriteLine("No Subdirectories to Remove");
                }

                int fileCount = Directory.GetFiles(path).Length;

                if(fileCount &gt; 0){

                    System.IO.DirectoryInfo di = new DirectoryInfo(path);

                    foreach (FileInfo file in di.GetFiles())
                    {
                            file.Delete(); 
                    }


                }
                else{

                    Console.WriteLine("No Files to Remove");
                }

                }
            else{

                Console.WriteLine("Path Doesn't Exist {0}", path);
            }
        }

        public static void readFromText(string pathtotext)
        {
                try
                {   // Open the text file using a stream reader.
                    using (StreamReader sr = new StreamReader(pathtotext))
                    {
                        // Read the stream to a string, and write the string to the console.
                        string line = sr.ReadToEnd();
                        clearPath(line);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("The file could not be read:");
                    Console.WriteLine(e.Message);
                }

        }

    }
}
</code></pre>

<p><strong>My Problem:</strong></p>

<p>When reading from the text file, it says that the first path doesn't exist, and prints all the paths to the prompt, despite that I have no <code>Console.WriteLine()</code>.  However, if I plug these same paths and call -tPath: it will work. My issue seems to be in the <code>readFromText()</code> I just can't seem to figure it out. </p>
