So this is part of a program that I am writing. I want the program to copy itself to a given location, write & run a batch file that kills the old process and runs the new one. The problem is that it is causing an infinite loop of the original program to be run and killed instead of the new version. Here is the code I am using.

```
string placementDirectory = Environment.GetFolderPath("Where I want to place the file");
string folderName = "KL";
string currentProccessDirectory = Environment.CurrentDirectory;
string currentProccessName = Process.GetCurrentProcess().ProcessName + ".exe";

if (currentProccessDirectory != placementDirectory + "\\" + folderName) //This is the check to see if it is in the correct directory
{
    if (Directory.GetDirectories(placementDirectory).Contains(placementDirectory + "\\" + folderName)) // This checks if the placement directory exists
    {
        if (Directory.GetFiles(placementDirectory + "\\" + folderName).Contains(placementDirectory + "\\" + folderName + "\\" + currentProccessName))
        {
            System.IO.File.Delete(placementDirectory + "\\" + folderName + "\\" + currentProccessName); // if the file already exists at this location, it deletes i
        }
    }
    else // if the Placement directory does not exist, it creates it
    {
        Directory.CreateDirectory(placementDirectory + "\\" + folderName);
    }
    System.IO.File.Copy(currentProccessDirectory + "\\" + currentProccessName, placementDirectory + "\\" + folderName + "\\" + currentProccessName); //Copies the running proccess to the desired location
    using (StreamWriter canWrite = new StreamWriter(placementDirectory + "\\" + folderName + "\\Copier.bat")) // Creation of the batch file to kill the and run the new proccess
    {
        canWrite.WriteLine("taskkill /f /im \"" + currentProccessName + "\"");
        canWrite.Write("START \"" + placementDirectory + "\\" + folderName + "\" " + "\"" + currentProccessName + "\"");
        canWrite.Flush();
    }
    Process.Start(placementDirectory + "\\" + folderName + "\\Copier.bat");
}

```

I for some reason the batch file always opens the original executable even though its told to open the new one. And I have no clue why.