62,072
社区成员
发帖
与我相关
我的任务
分享
public bool Upload(string filePath)//上传的
{
FileStream fs = null;
Stream stream = null;
try
{
FileInfo info = new FileInfo(filePath);
FtpWebRequest reqFtp = GetFtpWebRequest(info.Name);
int buffLength = 2048;
byte[] buff = new byte[buffLength];
fs = info.OpenRead();
stream = reqFtp.GetRequestStream();
int contentLen = fs.Read(buff, 0, buffLength);
while (contentLen != 0)
{
stream.Write(buff, 0, contentLen);
contentLen = fs.Read(buff, 0, buffLength);
}
return true;
}
catch (Exception)
{
return false;
}
finally
{
if (fs != null)
{
fs.Close();
}
if (stream != null)
{
stream.Close();
}
}
}
protected void btnUpload_Click(object sender, EventArgs e)//页面点击上传按钮的时候的
{
FtpUploader ftp = new FtpUploader();
foreach (string s in imgList)
{
ftp.Upload(s);
}
imgList.Clear();
}