I am trying to transfer an Excel file to the sftp site and my code is executing correctly, but I cannot see the file on the site.
private static void SendFile(string FileName)
{
FileStream rdr = new FileStream(FileName + ".csv", FileMode.Open);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://sftp.somesite.com");
HttpWebResponse resp;
req.Method = "Post";
req.Credentials = new NetworkCredential("UN", "PW", "Domain");
req.ContentLength = rdr.Length;
req.AllowWriteStreamBuffering = true;
Stream reqStream = req.GetRequestStream();
byte[] inData = new byte[rdr.Length];
int bytesRead = rdr.Read(inData, 0, Convert.ToInt32(rdr.Length));
reqStream.Write(inData, 0, Convert.ToInt32(rdr.Length));
rdr.Close();
}
I'm not sure what I am doing wrong in the code above. Thank you in advance for any help.
Eric source
share