How do I connect to my server from my C# application?

Jun 28 2012 4:05 PM
I have some code and everything looks liek it should work fine but when I get to getrequeststream it throws the exception. help!!!! 
 
public void uploadFile (string fileToUpload)
{
//create instance of login form to retrieve login data with created methods
loginForm lf = new loginForm();

//create FTP server login credentials
string serverUser =  lf.getLoginUser;
string serverPass = lf.getLoginPass;

try {
FileInfo toUpload = new FileInfo(fileToUpload);
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://stepcommoditiesllc.com/"+ toUpload.Name);
}
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials =
new NetworkCredential(serverUser, serverPass);
Stream ftpStream = request.GetRequestStream(); //<-here I get the error

int length = 1024;
byte[] buffer = new byte[length];
int bytesRead = 0;

FileStream file = File.OpenRead(fileToUpload);



do{
bytesRead = file.Read(buffer, 0, length);
ftpStream.Write(buffer, 0, bytesRead);
} while (bytesRead != 0);

file.Close();
ftpStream.Close();

catch
{
//Did not connect to server
MessageBox.Show("Error - Did Not Connect");
}