uploadRequest.Proxy = null;
NetworkCredential nc = new NetworkCredential();
//nc.Domain = "203.86.26.190";
nc.UserName = "milimall";
nc.Password = "wesdxc91";
// uploadRequest.UseBinary = true;
uploadRequest.Credentials = nc; //修改getCredential();错误2
requestStream = uploadRequest.GetRequestStream();
fileStream = File.Open(fileName, FileMode.Open);
byte[] buffer = new byte[1024];
int bytesRead;
while (true)
{
bytesRead = fileStream.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
break;
requestStream.Write(buffer, 0, bytesRead);
}
requestStream.Close();
uploadResponse = (FtpWebResponse)uploadRequest.GetResponse();
return uploadResponse.StatusCode;
}
catch (UriFormatException ex)
{
}
catch (IOException ex)
{
}
catch (WebException ex)
{
}
finally
{
if (uploadResponse != null)
uploadResponse.Close();
if (fileStream != null)
fileStream.Close();
if (requestStream != null)
requestStream.Close();
}
return FtpStatusCode.Undefined;
}
#endregion