当前位置:编程学习 > C#/ASP.NET >>

c#无法连接到ftp总是提示密码错误

使用sharpftpserver.dll​

通过c#语句打开ftp服务

private FtpServer ftpServer = new FtpServer();

ftpServer.start();

之后在cmd中键入命令

ftp

open ip地址

按提示 输入用户名密码(这个可以保证是正确的)

但是就是提示密码错误

 然后直接在网页中键入ftp://用户名:密码@ip地址

就出现一个对话框提示:要登录到该ftp服务器,请键入用户名和密码

请问该怎么解决? FTP C# --------------------编程问答-------------------- 说明你的sharpftpserver配置有问题 --------------------编程问答-------------------- 请问有用过这个类吗 要怎么配置 --------------------编程问答-------------------- 看起来project不怎么火啊,自己下载代码来调试下吧. --------------------编程问答-------------------- 哎  好无奈呵呵 --------------------编程问答-------------------- 看樣子c#是無所不能啊。學習。 --------------------编程问答-------------------- 把你的用户名和密码贴出来,“ftp://用户名:密码@ip地址”的形式是不允许出现特殊字符的,例如:“、@”等字符 --------------------编程问答-------------------- 例如“:”、“@”等字符 --------------------编程问答--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SharpFtpServer;
using System.Threading;
using System.Net;

namespace svn_update
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            if (!System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + @"\FtpConfig\"))
            {
                System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + @"\FtpConfig\");
            }
            if (!System.IO.Directory.Exists(System.Windows.Forms.Application.StartupPath + @"\Version\"))
            {
                System.IO.Directory.CreateDirectory(System.Windows.Forms.Application.StartupPath + @"\Version\");
            }

            FtpAuth.FtpAuthFilePath = System.Windows.Forms.Application.StartupPath + @"\FtpConfig\account.xml";

            FtpAuthArgs account = new FtpAuthArgs("aa", "aa", System.Windows.Forms.Application.StartupPath + @"\Version");
            FtpAuth.AddAccount(account);
            FtpAuth.SaveAccount();
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            update = new ClsUpdate();

            TupgradeTask task=new TupgradeTask();
            updateTable table = new updateTable();
          //  /*测试
            task.TFTPIP = "192.168.33.44";//任意Ip
            task.TFTPPORT = "21";
            task.LoginUser = "aa";
            task.LoginPassword = "aa";
            task.UpgFileName = "aa";
         //   */

            if (!(string.IsNullOrEmpty(textFileName.Text)&&string.IsNullOrEmpty(textIP.Text)&&string.IsNullOrEmpty(textPort.Text)
                &&string.IsNullOrEmpty(textUser.Text)&&string.IsNullOrEmpty(textPw.Text))&&flag)
            {
                //task.TFTPIP = textIP.Text;
                //task.TFTPPORT = textPort.Text;
                //task.LoginUser = textUser.Text;
                //task.LoginPassword = textPw.Text;
                //task.UpgFileName = textFileName.Text;

                update.getInfo(task, table);
                if (update.updateMaster())
                {
                    MessageBox.Show("升级成功", "提示");
                }
                else
                {
                    MessageBox.Show("升级失败", "提示");
                }
            }
            else
            {
                MessageBox.Show("数据不完整或文件缺失");
            }
        }

       // /*  以下发生错误  输入ftp密码错误无法连接上ftp 
        private void Form1_Load(object sender, EventArgs e)
        {
            this.FormClosing += new FormClosingEventHandler(Form1_FormClosing);
            string ftpPath = Application.StartupPath + "\\" + "Version\\";//后面加斜杆
            if (!System.IO.Directory.Exists(ftpPath))
            {
                MessageBox.Show("tftpd32.exe文件缺失");
                flag = false;
            }
            else
            {

                ftpServer.Start();
                startTftpProgram(ftpPath);
            }
        }
        void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            ftpServer.Stop();
        }
        private void startTftpProgram(string ftpPath)
        {
            //运行tftpd32.exe
            p = new System.Diagnostics.Process();
            //文件夹路径
            p.StartInfo.WorkingDirectory = ftpPath;
            //运行程序名
            p.StartInfo.FileName = ftpPath+"Tftpd32";//完整地址且不加扩展名
            p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            p.StartInfo.Arguments = "";
            if (!p.Start())
            {
                MessageBox.Show("Tftpd32.exe运行失败");
            }
        }
       // */

        private delegate void showState();
        private FtpServer ftpServer = new FtpServer();
        private Boolean flag = true;
        private System.Diagnostics.Process p;
        ClsUpdate update = null;
    }
}
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,