asp.net 怎么检测一个ftp ip 用户名 密码 是否正确?ftp服务器正常。本人不会asp.net,请各位高手尽量给出全的代码,谢谢!asp 貌似是无法实现的不写组件的话
解决方案 »
- 急求C#网页上对数据库修改、删除等常规操作
- .net控件嵌入数据源和其他控件的问题,急
- 请教一个问题
- 请问如何把下面的vb程序改写成C#
- 关于vs2008 安装后 iis 的问题
- 关于GridView扩展组件的问题,请高人指点
- JS全选问题 复选框是.net服务器控件checkBox 在GridView中的模板列
- 请教各位高手在acpx(页面组件)中用page.findcontrol方法访问它所在的aspx文件的问题?
- 关于CreateChildControls!
- 是什么问题
- 没有为 SQL 缓存通知启用数据库“ZooManageBase”。
- IIS部署的站点不能通过登录页进入系统,部署实施的灵异问题!
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.IO;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string ftpServerIP="";
private string ftpUserID="";
private string ftpPassword=""; private void button1_Click(object sender, EventArgs e)
{ }
private void Download(string filePath, string fileName)
{
FtpWebRequest reqFTP;
try
{
FileStream outputStream = new FileStream((filePath + "\\" + fileName), FileMode.Create);
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP+fileName));
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Stream ftpStream = response.GetResponseStream();
long cl = response.ContentLength;
int bufferSize = 2048;
int readCount;
byte[] buffer = new byte[bufferSize];
readCount = ftpStream.Read(buffer, 0, bufferSize);
while (readCount > 0)
{
outputStream.Write(buffer, 0, readCount);
readCount = ftpStream.Read(buffer, 0, bufferSize);
}
ftpStream.Close();
outputStream.Close();
response.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
} }
}}