此代码生成上面的错误,我试图做一些将文件发送到 ftp 服务器的方法
public void btnSend_Click(object sender, GridViewCommandEventArgs e)
{
msgerror = SP.StrSPBUS_DocClient(Convert.ToInt32(e.CommandArgument.ToString()));
if (msgerror.Equals("Sucess"))
{
String Files = SP.OUTSTR_NMDOCUMENT;
String Address = SP.OUTSTR_FTPCAM;
String User = SP.OUTSTR_FTPUSER;
String Pass = SP.OUTSTR_FTPPASS;
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Address + "/" + Path.GetFileName(File));
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(User, Pass);
request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = false;
var stream = File.OpenRead(Files);
byte[] buffer = new byte[stream.Length];
stream.Read(buffer, 0, buffer.Length);
stream.Close();
var reqStream = request.GetRequestStream();
reqStream.Write(buffer, 0, buffer.Length);
reqStream.Close();
}
else
{
SP.StrImprimeMessage("Error!");
return;
}
}
和文件 .aspx 这是按钮的代码
<tr class="tabelinner">
<td class="leftcell" valign="middle">
<asp:Button ID="btnSrend" runat="server" Text="Send" CssClass="ButtonLink" ValidationGroup="sending" CommandArgument="Sending" onclick="btnSend_Click" />
<br />
</td>
</tr>