日期:2014-05-18  浏览次数:20685 次

.NET实现FTP上传功能错误
我的前台代码如下:
<%@   Page   Language= "C# "   AutoEventWireup= "true "   CodeBehind= "FtpUpload.aspx.cs "   Inherits= "MyInterface.UseFtp.FtpUpload "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> Untitled   Page </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <input   id= "File1 "   runat= "server "   type= "file "   />
                <br   />
                <asp:Button   ID= "txtUpload "   runat= "server "   OnClick= "txtUpload_Click "   Text= "上传 "   />
                <asp:Label   ID= "lblP "   runat= "server "> </asp:Label> </div>
        </form>
</body>
</html>
主要是一个上传控件用来得到用户上传的文件路径.
一个提交按钮
后台代码如下:
using   System;
using   System.Data;
using   System.Configuration;
using   System.Collections;
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;

namespace   MyInterface.UseFtp
{
        public   partial   class   FtpUpload   :   System.Web.UI.Page
        {
                //ftp服务器IP
                string   ftpServerIP   =   ConfigurationSettings.AppSettings[ "ftpServerIP "];
                //ftp用户名
                string   ftpUserID   =   ConfigurationSettings.AppSettings[ "ftpUserID "];
                //ftp用户密码
                string   ftpPassword   =   ConfigurationSettings.AppSettings[ "ftpPassword "];
                protected   void   Page_Load(object   sender,   EventArgs   e)
                {

                }
                ///   <summary>
                ///   利用FTP上传
                ///   by   minjiang   07-09-05
                ///   </summary>
  &