登录FTP,需要:ip地址,用户名,密码
我现在有多个FTP,ip地址,用户名,密码,管理员都有
假如,我现在手里有1个  1.aspx 的文件,需要同时放入我现有的FTP空间上面。进行访问。
意思就是,把一个文件 同时上传到,不同的空间上面。
最简单的方式,就是多个FTP,就有多条记录喽。
比如FTP1   1.aspx
    FTP2   1.aspx
    FTP3   1.aspx我现在用DOS FTP,但不成功!~代码
www1.txt
open IP地址
账号
密码
cd ceshi
bin
prompt
mput "*.*"
bye
quit
exitd
我用的一个调用方法
一键上传多域名.bat
cd up
ftp -n -s:"d:\FTP\www1.txt"
知道原因的说下,或者有源文件的大大贴出来下,谢谢了

解决方案 »

  1.   


    /// <summary>
            /// 执行下载
            /// </summary>
            /// <returns></returns>
            public void DownAutoUpdateFile()
            {
                XmlDocument doc = new XmlDocument();
                doc.Load("./Update/update.xml");                   //下载更新的XML模板的路径
                XmlElement root = doc.DocumentElement;
                XmlNode updateNode = root.SelectSingleNode("updateurl");            //看看更新的Url
                string downpath = updateNode.Attributes["url"].Value;            string serverXmlFile = downpath + @"/update.xml";
                UpdaterUrl = serverXmlFile;            WebRequest req = WebRequest.Create(UpdaterUrl);
                req.Credentials = new NetworkCredential("账号", "密码");
                FtpWebResponse res = req.GetResponse() as FtpWebResponse;
                Stream ftpStream = res.GetResponseStream();
                FileStream outStream = File.OpenWrite(Application.StartupPath + @"\update.xml");            string fileSize = GetM(Convert.ToInt64(res.Headers["Content-Length"]));
                long currentSize = 0;
                byte[] buffer = new byte[2048];
                int size = 0;
                while ((size = ftpStream.Read(buffer, 0, 2048)) > 0)
                {
                    outStream.Write(buffer, 0, size);
                    currentSize += size;
                        Console.WriteLine(string.Format("{0}/{1}......", GetM(currentSize), fileSize));
                }
                MessageBox.Show(DateTime.Now.ToString() + ",完成下载!");
                ftpStream.Close();
                outStream.Close();
            }        private static string GetM(long i)
            {
                if (i > 0)
                    return (((decimal)i / 1024) / 1024).ToString("0.00") + "M";
                else
                    return "0M";
            }
      

  2.   

    http://blog.csdn.net/vainnetwork/archive/2007/07/31/1720361.aspx
    这里有一个,可以参考.
      

  3.   

    using System.Net; 
    using System.IO; //调用以下函数 
    private FtpStatusCode UploadFun(string fileName, string uploadUrl) 

    Stream requestStream = null; 
    FileStream fileStream = null; 
    FtpWebResponse uploadResponse = null; 
    try 

    FtpWebRequest uploadRequest = 
    (FtpWebRequest)WebRequest.Create(uploadUrl); 
    uploadRequest.Method = WebRequestMethods.Ftp.UploadFile; uploadRequest.Proxy = null; 
    NetworkCredential nc = new NetworkCredential(); 
    nc.UserName = "aa"; 
    nc.Password = "aa123"; 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; 
    } //调用例子 
    FtpStatusCode status = UploadFun(@"d:\1\1.txt", "ftp://域名/目录/保存文件名"); 
    FtpStatusCode返回状态说明:FtpStatusCode指定为文件传输协议 (FTP) 操作返回的状态代码。AccountNeeded 指示需要服务器上的用户帐户。
    ActionAbortedLocalProcessingError 指示发生了阻止完成请求操作的错误。
    ActionAbortedUnknownPageType 指示不能采取请求的操作,因为指定的页类型是未知的。RFC 959 的 3.1.2.3 节中介绍了页类型
    ActionNotTakenFilenameNotAllowed 指定无法对指定文件执行请求的操作。
    ActionNotTakenFileUnavailable 指定无法对指定文件执行请求的操作,原因是该文件不可用。
    ActionNotTakenFileUnavailableOrBusy 指定无法对指定文件执行请求的操作,原因是该文件不可用或正在使用中。
    ActionNotTakenInsufficientSpace 指示不能执行请求的操作,因为服务器上没有足够的空间。
    ArgumentSyntaxError 指示一个或多个命令参数具有语法错误。
    BadCommandSequence 指示命令序列的顺序不正确。
    CantOpenData 指示无法打开数据连接。
    ClosingControl 指示服务器正在关闭管理连接。
    ClosingData 指示服务器正在关闭数据连接,并且请求的文件操作成功。
    CommandExtraneous 指示服务器未执行该命令,因为无需此命令。
    CommandNotImplemented 指示 FTP 服务器未执行该命令。
    CommandOK 指示命令成功完成。
    CommandSyntaxError 指示命令具有语法错误或不是服务器可识别的命令。
    ConnectionClosed 指示连接已关闭。
    DataAlreadyOpen 指示数据连接已打开并且请求的传输已开始。
    DirectoryStatus 指示目录状态。
    EnteringPassive 指示服务器正在进入被动模式。
    FileActionAborted 指示不能执行请求的操作。
    FileActionOK 指示请求的文件操作成功完成。
    FileCommandPending 指示请求的文件操作需要其他信息。
    FileStatus 指示文件状态。
    LoggedInProceed 指示用户已登录且可发送命令。
    NeedLoginAccount 指示服务器需要提供登录帐户。
    NotLoggedIn 指示登录信息必须发送到服务器。
    OpeningData 指示服务器正在打开数据连接。
    PathnameCreated 指示请求的路径名已创建。
    RestartMarker 指示响应包含一个重新启动标记回复。此状态附带的说明文本包含用户数据流标记和服务器标记。
    SendPasswordCommand 指示服务器需要提供密码。
    SendUserCommand 指示服务器已能进行用户登录操作。
    ServerWantsSecureSession 指示服务器接受客户端指定的身份验证机制,并且安全数据交换完成。
    ServiceNotAvailable 指示此服务不可用。
    ServiceTemporarilyNotAvailable 指示此服务现在不可用;请稍后再试您的请求。
    SystemType 指示使用 Internet Assigned Numbers Authority(Internet 号码分配机构)出版的 Assigned Numbers(号码分配)文档中发布的系统名的系统类型名称。
    Undefined 包含此值是为了完整性,服务器从不返回此值。这个更容易理解。原文出自:http://blog.sina.com.cn/s/blog_4c6e822d0100ib3v.html