我正在尝试将 Excel 文件传输到 sftp 站点,并且我的代码可以正常执行,但我在站点上看不到该文件。
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();
}
我在上面的代码中做错了什么?