FTP文件上传以及获取ftp配置帮助类

帮助类:

using QSProjectBase;
using Reform.CommonLib;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;

namespace Reform.CommonLib
{
    /// <summary>
    /// ftp操作
    /// </summary>
    public class FtpHelper
    {
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="fileName">上传文件的全路径</param>
        /// <param name="accessory">上传类</param>
        /// <returns></returns>
        public static bool UploadFile(FileInfo fileinfo, string ftpPath)
        {
            try
            {
                if (fileinfo == null || string.IsNullOrEmpty(ftpPath))
                    return false;

                string url = ftpPath;
                if (url.Contains("/") || url.Contains("\\"))
                {
                    var str = url.Split(new Char[] { ‘/‘, ‘\\‘ });
                    var dic = url.Replace(str[str.Length - 1], "");
                    CheckAndMakeDir(dic);
                }

                System.Net.FtpWebRequest ftp = GetRequest(url);

                //设置FTP命令 设置所要执行的FTP命令,
                //ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;//假设此处为显示指定路径下的文件列表
                ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
                ftp.UseBinary = true;
                ftp.UsePassive = true;
                ftp.ContentLength = fileinfo.Length;

                const int BufferSize = 20480; //缓冲大小设置为20KB
                byte[] content = new byte[BufferSize - 1 + 1];
                int dataRead;

                using (FileStream fs = fileinfo.OpenRead())
                {
                    try
                    {
                        using (Stream rs = ftp.GetRequestStream())
                        {
                            do
                            {
                                dataRead = fs.Read(content, 0, BufferSize);
                                rs.Write(content, 0, dataRead);
                            } while (!(dataRead < BufferSize));
                            rs.Close();
                        }
                    }
                    catch (Exception) { }
                    finally
                    {
                        fs.Close();
                    }
                }
                ftp = null;
                ////设置FTP命令
                //ftp = GetRequest(URI);
                //ftp.Method = System.Net.WebRequestMethods.Ftp.Rename; //改名
                //ftp.RenameTo = fileinfo.Name;
                //try
                //{
                //    ftp.GetResponse();
                //}
                //catch (Exception ex)
                //{
                //    ftp = GetRequest(URI);
                //    ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile; //删除
                //    ftp.GetResponse();
                //}
                //ftp = null;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="fileName">上传文件的全路径</param>
        /// <param name="ftpPath">上传的目录(包括文件名)</param>
        /// <param name="progressHelper">进度帮助</param>
        /// <returns></returns>
        public static bool UploadFile(FileInfo fileinfo, string ftpPath, ProgressHelper progressHelper, MessageProgressHandler handler)
        {
            try
            {
                if (fileinfo == null || string.IsNullOrEmpty(ftpPath))
                    return false;

                string url = ftpPath;
                if (url.Contains("/") || url.Contains("\\"))
                {
                    var str = url.Split(new Char[] { ‘/‘, ‘\\‘ });
                    var dic = url.Replace(str[str.Length - 1], "");
                    CheckAndMakeDir(dic);
                }
                System.Net.FtpWebRequest ftp = GetRequest(url);

                //设置FTP命令 设置所要执行的FTP命令,
                //ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectoryDetails;//假设此处为显示指定路径下的文件列表
                ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile;
                ftp.UseBinary = true;
                ftp.UsePassive = false;
                ftp.ContentLength = fileinfo.Length;

                const int BufferSize = 20480; //缓冲大小设置为20KB
                byte[] content = new byte[BufferSize - 1 + 1];
                int dataRead;

                using (FileStream fs = fileinfo.OpenRead())
                {
                    long fileLen = fs.Length;
                    if (progressHelper != null && handler != null)
                    {
                        progressHelper.SetProgress(handler, "正在上传...", 0);
                    }
                    try
                    {
                        long proValue = 0;
                        using (Stream rs = ftp.GetRequestStream())
                        {

                            do
                            {
                                dataRead = fs.Read(content, 0, BufferSize);
                                rs.Write(content, 0, dataRead);
                                proValue += dataRead;
                                if (progressHelper != null && handler != null)
                                {
                                    progressHelper.SetProgress(handler, "正在上传...", (int)((double)proValue * 100 / fileLen));
                                }
                            } while (!(dataRead < BufferSize));
                            var aa = rs.Length;
                            rs.Close();
                        }
                    }
                    catch (Exception) { }
                    finally
                    {
                        fs.Close();
                    }
                }
                ftp = null;
                ////设置FTP命令
                //ftp = GetRequest(URI);
                //ftp.Method = System.Net.WebRequestMethods.Ftp.Rename; //改名
                //ftp.RenameTo = fileinfo.Name;
                //try
                //{
                //    ftp.GetResponse();
                //}
                //catch (Exception ex)
                //{
                //    ftp = GetRequest(URI);
                //    ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile; //删除
                //    ftp.GetResponse();
                //}
                //ftp = null;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="localDir">下载到本地(全路径)</param>
        /// <param name="accessory">要下载的附件类</param>
        public static bool DownloadFile(string localFilePath, string ftpPath)
        {
            if (string.IsNullOrEmpty(ftpPath)) return false;
            if (string.IsNullOrEmpty(localFilePath)) return false;
            System.Net.FtpWebRequest ftp = null;
            try
            {
                string Url = ftpPath;
                string localDir = new FileInfo(localFilePath).DirectoryName;
                if (!Directory.Exists(localDir))
                {
                    Directory.CreateDirectory(localDir);
                }
                string tmpname = Guid.NewGuid().ToString();
                string tmpFilePath = localDir + @"\" + tmpname;

                ftp = GetRequest(Url);
                // MsgBoxShow.ShowInformation(Url);
                ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
                ftp.UseBinary = true;
                ftp.UsePassive = false;

                using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        using (FileStream fs = new FileStream(tmpFilePath, FileMode.CreateNew))
                        {
                            var aa = ftp.ContentLength;
                            try
                            {
                                byte[] buffer = new byte[20480];
                                int read = 0;
                                do
                                {
                                    read = responseStream.Read(buffer, 0, buffer.Length);
                                    fs.Write(buffer, 0, read);
                                } while (!(read == 0));
                                responseStream.Close();
                                fs.Flush();
                                fs.Close();
                            }
                            catch (Exception)
                            {
                                fs.Close();
                                File.Delete(tmpFilePath);
                                return false;
                            }
                        }
                        responseStream.Close();
                    }
                    response.Close();
                }
                try
                {
                    File.Delete(localFilePath);
                    File.Move(tmpFilePath, localFilePath);
                    ftp = null;
                }
                catch (Exception)
                {
                    File.Delete(tmpFilePath);
                    return false;
                }
                ftp = null;
                return true;
            }
            catch (WebException e)
            {
                Common_LogManager.RecordLog(LogType.Error, e.Message, e);
                if (e.Status == WebExceptionStatus.ProtocolError)
                {
                    Console.WriteLine("Status Code : {0}", ((FtpWebResponse)e.Response).StatusCode);
                    Console.WriteLine("Status Description : {0}", ((FtpWebResponse)e.Response).StatusDescription);
                }
                return false;
            }
        }

        /// <summary>
        /// 下载文件,叠加
        /// </summary>
        /// <param name="localDir">下载到本地(全路径)</param>
        /// <param name="accessory">要下载的附件类</param>
        public static bool DownloadFileEx(string localFilePath, string ftpPath)
        {
            if (string.IsNullOrEmpty(ftpPath)) return false;
            if (string.IsNullOrEmpty(localFilePath)) return false;
            try
            {
                string Url = ftpPath;

                System.Net.FtpWebRequest ftp = GetRequest(Url);
                ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
                ftp.UseBinary = true;
                ftp.UsePassive = false;

                using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        using (FileStream fs = new FileStream(localFilePath, FileMode.Append))
                        {
                            try
                            {
                                byte[] buffer = new byte[20480];
                                int read = 0;
                                do
                                {
                                    read = responseStream.Read(buffer, 0, buffer.Length);
                                    fs.Write(buffer, 0, read);
                                } while (!(read == 0));
                                responseStream.Close();
                                fs.Flush();
                                fs.Close();
                            }
                            catch (Exception)
                            {
                                fs.Close();
                                return false;
                            }
                        }
                        responseStream.Close();
                    }
                    response.Close();
                }
                try
                {
                    ftp = null;
                }
                catch (Exception)
                {
                    return false;
                }
                ftp = null;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// 下载文件(包含进度)
        /// </summary>
        /// <param name="localDir">下载到本地(全路径)</param>
        /// <param name="accessory">要下载的附件类</param>
        public static bool DownloadFile(string localFilePath, string ftpPath, ProgressHelper progressHelper, MessageProgressHandler handler)
        {
            if (string.IsNullOrEmpty(ftpPath)) return false;
            if (string.IsNullOrEmpty(localFilePath)) return false;

            try
            {
                string URI = ftpPath;
                string localDir = new FileInfo(localFilePath).DirectoryName;

                string tmpname = Guid.NewGuid().ToString();
                string tmpFilePath = localDir + @"\" + tmpname;

                System.Net.FtpWebRequest ftp = GetRequest(URI);
                ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
                ftp.UseBinary = true;
                ftp.UsePassive = false;
                long fileLen = GetFileSize(ftpPath);
                using (WebResponse response = ftp.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        if (progressHelper != null && handler != null)
                        {
                            progressHelper.SetProgress(handler, "正在下载...", 0);
                        }
                        using (FileStream fs = new FileStream(tmpFilePath, FileMode.OpenOrCreate))
                        {
                            try
                            {
                                long proValue = 0;
                                byte[] buffer = new byte[20480];
                                int read = 0;
                                do
                                {
                                    read = responseStream.Read(buffer, 0, buffer.Length);
                                    fs.Write(buffer, 0, read);
                                    proValue += read;
                                    if (progressHelper != null && handler != null)
                                    {
                                        progressHelper.SetProgress(handler, "正在下载...", (int)((double)proValue * 100 / fileLen));
                                    }
                                } while (!(read == 0));
                                responseStream.Close();
                                fs.Flush();
                                fs.Close();
                            }
                            catch (Exception)
                            {
                                fs.Close();
                                File.Delete(tmpFilePath);
                                return false;
                            }
                        }
                        responseStream.Close();
                    }
                    response.Close();
                }
                try
                {
                    File.Delete(localFilePath);
                    File.Move(tmpFilePath, localFilePath);
                    ftp = null;
                }
                catch (Exception ex)
                {
                    File.Delete(tmpFilePath);
                    return false;
                }
                ftp = null;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="accessory">要删除的附件全路径</param>
        public static bool DeleteFile(string ftpPath)
        {
            if (string.IsNullOrEmpty(ftpPath)) return false;
            try
            {
                string URI = ftpPath;
                System.Net.FtpWebRequest ftp = GetRequest(URI);
                ftp.Method = System.Net.WebRequestMethods.Ftp.DeleteFile;
                ftp.UseBinary = true;
                ftp.UsePassive = false;
                using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        responseStream.Close();
                    }
                    response.Close();
                }
                ftp = null;
                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }

        /// <summary>
        /// 搜索远程文件
        /// </summary>
        /// <param name="targetDir">文件夹</param>
        /// <param name="SearchPattern">搜索模式</param>
        /// <returns></returns>
        public static List<string> ListDirectory(string targetDir, string SearchPattern)
        {
            List<string> result = new List<string>();
            try
            {
                string URI = targetDir + "/" + SearchPattern;
                System.Net.FtpWebRequest ftp = GetRequest(URI);
                ftp.Method = System.Net.WebRequestMethods.Ftp.ListDirectory;
                ftp.UsePassive = true;
                ftp.UseBinary = true;

                string str = GetStringResponse(ftp);
                str = str.Replace("\r\n", "\r").TrimEnd(‘\r‘);
                str = str.Replace("\n", "\r");
                if (str != string.Empty)
                    result.AddRange(str.Split(‘\r‘));

                return result;
            }
            catch { }
            return null;
        }

        private static string GetStringResponse(FtpWebRequest ftp)
        {
            string result = "";
            using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
            {
                long size = response.ContentLength;
                using (Stream datastream = response.GetResponseStream())
                {
                    using (StreamReader sr = new StreamReader(datastream, System.Text.Encoding.Default))
                    {
                        result = sr.ReadToEnd();
                        sr.Close();
                    }

                    datastream.Close();
                }

                response.Close();
            }

            return result;
        }

        public static void CheckAndMakeDir(string dirName)
        {
            if (string.IsNullOrEmpty(dirName))
            {
                return;
            }
            if (dirName.Contains("/") || dirName.Contains("\\"))
            {
                var str = dirName.Split(new Char[] { ‘/‘, ‘\\‘ });
                if (str.Length == 0 || string.IsNullOrEmpty(str[0]))
                {
                    return;
                }
                string dir = str[0] + "/";
                if (!IsExistsFile(dir))
                    MakeDir(dir);
                for (int i = 1; i < str.Length; i++)
                {
                    if (string.IsNullOrEmpty(str[i]))
                    {
                        continue;
                    }
                    dir += (str[i] + "/");
                    if (!IsExistsFile(dir))
                        MakeDir(dir);
                }

            }
            else
            {
                if (!IsExistsFile(dirName))
                    MakeDir(dirName);
            }
        }
        ///
        /// 在ftp服务器上创建目录
        /// </summary>
        /// <param name="dirName">创建的目录名称</param>
        public static void MakeDir(string dirName)
        {
            try
            {
                System.Net.FtpWebRequest ftp = GetRequest(dirName);
                ftp.Method = WebRequestMethods.Ftp.MakeDirectory;

                FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
                response.Close();
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message);
            }
        }

        /// <summary>
        /// 删除目录
        /// </summary>
        /// <param name="dirName">删除目录名称</param>
        public static bool delDir(string dirName)
        {
            try
            {
                System.Net.FtpWebRequest ftp = GetRequest(dirName);
                ftp.Method = WebRequestMethods.Ftp.RemoveDirectory;
                FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
                response.Close();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 文件重命名
        /// </summary>
        /// <param name="currentFilename">当前目录名称</param>
        /// <param name="newFilename">重命名目录名称</param>
        public static bool Rename(string currentFilename, string newFilename)
        {
            try
            {
                FileInfo fileInf = new FileInfo(currentFilename);
                System.Net.FtpWebRequest ftp = GetRequest(fileInf.Name);
                ftp.Method = WebRequestMethods.Ftp.Rename;

                ftp.RenameTo = newFilename;
                FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();

                response.Close();
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }

        private static FtpWebRequest GetRequest(string dirName)
        {
            string url = "ftp://" + ConfigHepler.FtpServer + "/" + dirName;
            //根据服务器信息FtpWebRequest创建类的对象
            FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(url);
            //提供身份验证信息
            result.Credentials = new System.Net.NetworkCredential(ConfigHepler.FtpUser, ConfigHepler.FtpPwd);
            //设置请求完成之后是否保持到FTP服务器的控制连接,默认值为true
            result.KeepAlive = false;

            return result;
        }

        /// <summary>
        /// 判断ftp服务器上该目录是否存在
        /// </summary>
        /// <param name="dirName"></param>
        /// <returns></returns>
        public static bool IsExistsFile(string dirName)
        {
            bool flag = true;
            try
            {
                System.Net.FtpWebRequest ftp = GetRequest(dirName);
                ftp.Method = WebRequestMethods.Ftp.ListDirectory;

                FtpWebResponse response = (FtpWebResponse)ftp.GetResponse();
                response.Close();
            }
            catch (Exception)
            {
                flag = false;
            }
            return flag;
        }

        // 获取文件大小
        public static long GetFileSize(string ftpPath)
        {
            long size = 0;
            if (string.IsNullOrEmpty(ftpPath)) return size;
            try
            {
                string URI = ftpPath;

                System.Net.FtpWebRequest ftp = GetRequest(URI);
                ftp.Method = System.Net.WebRequestMethods.Ftp.GetFileSize;
                ftp.UseBinary = true;
                ftp.UsePassive = false;

                using (FtpWebResponse response = (FtpWebResponse)ftp.GetResponse())
                {

                    size = response.ContentLength;

                }

            }
            catch (Exception)
            {

            }
            return size;
        }

    }

    /// <summary>
    /// 从配置文件获取配置信息
    /// </summary>
    public class ConfigHepler
    {
        private static string m_FtpServer;
        private static string m_FtpUser;
        private static string m_FtpPwd;
        /// <summary>
        /// ftp服务器
        /// </summary>
        public static string FtpServer
        {
            get
            {
                if (string.IsNullOrEmpty(m_FtpServer))
                {
                    string[] ftpConfigs = GlobalVars.FtpConfig.Split(new char[] { ‘;‘ });
                    if (ftpConfigs != null && ftpConfigs.Length > 0)
                        m_FtpServer = ftpConfigs[0];
                }

                return m_FtpServer;
            }
        }

        /// <summary>
        /// ftp用户名
        /// </summary>
        public static string FtpUser
        {
            get
            {
                if (string.IsNullOrEmpty(m_FtpUser))
                {
                    string[] ftpConfigs = GlobalVars.FtpConfig.Split(new char[] { ‘;‘ });
                    if (ftpConfigs != null && ftpConfigs.Length > 1)
                        m_FtpUser = ftpConfigs[1];
                }

                return m_FtpUser;
            }
        }

        /// <summary>
        /// ftp密码
        /// </summary>
        public static string FtpPwd
        {
            get
            {
                if (string.IsNullOrEmpty(m_FtpPwd))
                {
                    string[] ftpConfigs = GlobalVars.FtpConfig.Split(new char[] { ‘;‘ });
                    if (ftpConfigs != null && ftpConfigs.Length > 2)
                        m_FtpPwd = ftpConfigs[2];
                }

                return m_FtpPwd;
            }
        }
    }

}

配置文件配置:

<!--ftp配置,以分号相隔 格式:"主机名;用户名;密码;"-->
例子:<Item key="FtpConfig" value="192.168.0.1;admin;123456" />

上传调用例子:

FileInfo fInfo = new FileInfo(txtDoc.Text);
 //上传到ftp的完整目录,FTP目录+文件格式+日期+GUID+文件名+文件后缀
ftpPath = M_FTPDIRECTORY + m_Archives.DocType.Replace(".", "") + "/" + DateTime.Now.ToString("yyyyMMdd") + "/" + Guid.NewGuid().ToString() + "/" + m_Archives.DocName + m_Archives.DocType;
 bool suc = FtpHelper.UploadFile(fInfo, ftpPath);
时间: 2024-10-17 23:17:56

FTP文件上传以及获取ftp配置帮助类的相关文章

Quartz石英调度实现ftp文件上传

Quartz石英调度实现ftp文件上传 实现一个每月1号00点01分自动生成的文件,通过ftp传到另一台主机上 1.先创建一个job任务类FtpUploadFileJobTask import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import org.apache.commons.net

FTP文件上传与下载

实现FTP文件上传与下载可以通过以下两种种方式实现,分别为:1.通过JDK自带的API实现:2.通过Apache提供的API是实现. 第一种方式 [java] view plaincopy package com.cloudpower.util; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import sun.n

Java使用comms-net jar包完成ftp文件上传进度的检测功能

本文章只讲述大致的思路与本次功能对应的一些开发环境,具体实现请结合自己的开发情况,仅供参考,如果有不对的地方,欢迎大家指出! 准备环境:JDK1.7 OR 1.8.eclipse.ftp服务器(可自行搭建).comms-net jar包3.3版本的.其余的就不详细列举了. 1.在现实开发中ftp服务器和项目的部署服务器基本不会是同一台,所以基础springmvc的文件上传进度获取,只能获取到文件的二进制流到达项目后台的进度.对于真实的ftp文件上传进度,需要使用comms-net提供的监听器来实

【问题分析】FTP文件上传与下载

问题描述:通常应用服务器与文件服务器分别在不同的机器上,涉及到文件的上传与下载.通过建立网络映射盘的形式,将文件服务器保存文件的文件夹映射到应用服务器的某个盘符下,经过试验,在tomcat下两台笔记本是可以实现的,但是在生产环境的websphere下试验,经过多番尝试,仍然实现不了. 问题分析:采用FTP的方式实现文件的上传与下载功能,在Java代码中编写客户端的上传与下载,在文件服务器上,直接装一个FTP服务器软件即可.注意生产环境的防火墙以及客户是否允许使用FTP. 解决方案: 工程中导入J

Java实现FTP文件上传与下载

实现FTP文件上传与下载可以通过以下两种种方式实现(不知道还有没有其他方式),分别为:1.通过JDK自带的API实现:2.通过Apache提供的API是实现. 第一种方式 package com.cloudpower.util; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import sun.net.Telnet

FTP文件上传下载及验证

FTP文件上传下载及验证 有时候经常用到FTP的上传下载,本身代码相对比较简单,但有时需要考虑到文件上传下载进行验证.大体思路是上传时将FTP日志重定向到本地文件,再根据FTP返回码进行检查,这样有个缺点就是不能检验文件上传的完整性:下载时利用ls,ll命令查看是否存在. 上传代码 uploadFile() { ftp -i -v -n <<! >/tmp/ftp.log open $FTP_IP $FTP_PORT user $USER_ID $PASSWORD prompt cd $

张明贵-Linux文件上传下载及sCRT配置批量管理功能

[讲课:互动,用提问的方式来吸引听众的注意力,听众吸收最大化] 大学是在许昌学院读的,在我看来,不干念PPT的老师就是好讲师,因为大部分任课老师自顾自讲,没有互动,传授的知识我们只是被动的听,没有引导听课者的思考,再此吐槽一下,哈哈!我还是真心希望我的母校越来越好. 文件的上传下载 rz 上传 rz命令不存在 [[email protected] ~]# rz -bash: rz: command not found 安装 lrzsz(需要联网或配置yum源) yum install lrzsz

SWFUpload插件+FTP文件上传,我这么玩

效果图: 虽然之前接触过swfupload这个上传插件,但是之前做的样子是这样的 实战项目做的这么丑爆了我估计老大的内心是会崩溃的,所以特地在网上找了美观一点的样式,原帖地址:http://www.xiariboke.com/article/200.html 原帖后台是基于php写的插件,虽然各位看官也许没学过php但是也应该见过php跑,后台改成c#代码就可以了. 前台页面是一样的,在引入一堆js文件之后,改动一下对js文件的引用路径即可,比如这样: 由于原版直接使用页面会有乱码 我也懒得测试

【FTP】FTP文件上传下载-支持断点续传

Jar包:apache的commons-net包: 支持断点续传 支持进度监控(有时出不来,搞不清原因) 相关知识点 编码格式: UTF-8等; 文件类型: 包括[BINARY_FILE_TYPE(常用)]和[ASCII_FILE_TYPE]两种; 数据连接模式:一般使用LocalPassiveMode模式,因为大部分客户端都在防火墙后面: 1. LocalPassiveMode:服务器端打开数据端口,进行数据传输: 2. LocalActiveMode:客户端打开数据端口,进行数据传输: 系统