# Solved: File path whitespace problem in C# app



## jonathan.ownbey (Jan 5, 2007)

I have a an application that creates and runs a batch file for an ftp process. I have the download set to the absolute path of the app. When I attempt to run this app in debug, the batch file fails because of the whitespace in the download path.

Any advice is appreciated. I am still in the process of scouring the web for an answer. Code follows:


```
try
{
     DirInfo = new DirectoryInfo("BatchFiles/");
     if (!DirInfo.Exists)
     DirInfo.Create();
     BatFile = new FileInfo(DirInfo.FullName + "BatFile.bat");
     TextFile = new FileInfo(DirInfo.FullName + "BatFile");
     TrackerBat = new FileInfo(DirInfo.FullName + "TrackerBat.bat");
}
catch (Exception error)
```


```
using (StreamWriter sw = TextFile.CreateText())
{
     sw.WriteLine("open " + ftpIpAddress);
     sw.WriteLine("user");
     sw.WriteLine(ftpLogin);
     sw.WriteLine(ftpPassword);
     sw.WriteLine("lcd " + DirInfo.FullName);
     sw.WriteLine("mget pVQI" + date.ToString("MMdd") + "*.zip");
     sw.WriteLine("pause");
     sw.WriteLine("quit");
     sw.Close();
}
```


```
ProcessStartInfo psi = new ProcessStartInfo(BatFile.FullName);
psi.RedirectStandardOutput = false;
psi.WindowStyle = ProcessWindowStyle.Minimized;
psi.UseShellExecute = false;
Process ftp = Process.Start(psi);
StreamReader output = ftp.StandardOutput;
ftp.WaitForExit();
if (ftp.HasExited)
{
     rtbOutput.AppendText("FTP process ended.\n");
     string line;
     while (!output.EndOfStream)
     {
          line = output.ReadLine();
          rtbOutput.AppendText(line + "\n");
     }
}
else
{ }
```


----------



## JohnWill (Oct 19, 2002)

Have you tried putting quotes around the entire string when it's built?


----------



## jonathan.ownbey (Jan 5, 2007)

I tried that this morning and it worked like a charm. I don't know what the eff was wrong with me yesterday.

Thank you, and I'll mark this one as solved...


----------

