• 大小: 3.15MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-03-14
  • 语言: C#
  • 标签: ftp  上传  下载  

资源简介

C# ftp多线程断点上传下载

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Collections;
using System.IO;
using System.xml;

namespace Common
{
    public class AppUpdate
    {
        private string _updaterUrl;

        public string UpdaterUrl
        {
            set { _updaterUrl = value; }
            get { return this._updaterUrl; }
        }

        public void DownAutoUpdateFile(string downLoadPath)
        {
            if (!System.IO.Directory.Exists(downLoadPath))
                System.IO.Directory.CreateDirectory(downLoadPath);
            string serverxmlFile = downLoadPath + @“/UpdateList.xml“;
            try
            {
                WebRequest request = WebRequest.Create(_updaterUrl);
                WebResponse response = request.GetResponse();
                if (response.ContentLength > 0)
                {
                    WebClient client = new WebClient();
                    client.DownloadFile(this._updaterUrl serverxmlFile);
                }
            }
            catch 
            {
                return;
            }
        }

        public int CheckForUpdate(string serverxmlFile string localxmlFile out Hashtable updateFileList)
        {
            updateFileList = new Hashtable();
            if (!File.Exists(localxmlFile) || !File.Exists(serverxmlFile))
            {
                return -1;
            }

            xmlFiles serverxmlFiles = new xmlFiles(serverxmlFile);
            xmlFiles localxmlFiles = new xmlFiles(localxmlFile);

            xmlNodeList newNodeList = serverxmlFiles.GetNodeList(“AutoUpdater/Files“);
            xmlNodeList oldNodeList = localxmlFiles.GetNodeList(“AutoUpdater/Files“);//5+1+a+s+p+x

            int k = 0;
            for (int i = 0; i < newNodeList.Count; i++)
            {
                string[] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes[“Name“].Value.Trim();
                string newVer = newNodeList.Item(i).Attributes[“Ver“].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for (int j = 0; j < oldNodeList.Count; j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes[“Name“].Value.Trim();
                    string oldVer = oldNodeList.Item(j).Attributes[“Ver“].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);

                }
                int pos = oldFileAl.IndexOf(newFileName);
                if (pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k fileList);
                    k++;
                }
                else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) > 0)
                {
                    file

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3230  2008-03-22 14:02  Common\AppUpdate.cs

     文件      11264  2010-08-30 09:24  Common\bin\Debug\Common.dll

     文件      32256  2010-08-30 09:24  Common\bin\Debug\Common.pdb

     文件       5632  2010-08-30 09:24  Common\bin\Debug\Model.dll

     文件      19968  2010-08-30 09:24  Common\bin\Debug\Model.pdb

     文件      10752  2008-03-29 09:21  Common\bin\Release\Common.dll

     文件      38400  2008-03-29 09:21  Common\bin\Release\Common.pdb

     文件       5632  2010-08-21 08:37  Common\bin\Release\Model.dll

     文件      19968  2010-08-21 08:36  Common\bin\Release\Model.pdb

     文件       3879  2008-03-25 15:31  Common\Comm.cs

     文件       2949  2008-03-22 12:24  Common\Common.csproj

     文件       4892  2008-03-22 10:31  Common\ExtractIcon.cs

     文件       2922  2010-08-30 11:14  Common\obj\Debug\Common.csproj.FileListAbsolute.txt

     文件      11264  2010-08-30 09:24  Common\obj\Debug\Common.dll

     文件      32256  2010-08-30 09:24  Common\obj\Debug\Common.pdb

     文件       6656  2008-03-25 17:02  Common\obj\Debug\Refactor\Common.dll

     文件       3657  2010-08-30 11:14  Common\obj\Debug\ResolveAssemblyReference.cache

     文件       1608  2008-03-25 15:13  Common\obj\Release\Common.csproj.FileListAbsolute.txt

     文件      10752  2008-03-29 09:21  Common\obj\Release\Common.dll

     文件      38400  2008-03-29 09:21  Common\obj\Release\Common.pdb

     文件       6656  2010-08-18 22:35  Common\obj\Release\Refactor\Common.dll

     文件       4755  2008-03-29 09:16  Common\obj\Release\ResolveAssemblyReference.cache

     文件       1436  2008-03-11 16:27  Common\Properties\AssemblyInfo.cs

     文件       1198  2008-03-16 09:36  Common\SerializeClass.cs

     文件       1965  2008-03-25 15:31  Common\xmlFiles.cs

     文件       5632  2010-08-30 09:24  Model\bin\Debug\Model.dll

     文件      19968  2010-08-30 09:24  Model\bin\Debug\Model.pdb

     文件       5632  2010-08-21 08:37  Model\bin\Release\Model.dll

     文件      19968  2010-08-21 08:36  Model\bin\Release\Model.pdb

     文件        527  2008-03-25 17:03  Model\BookMark.cs

............此处省略290个文件信息

评论

共有 条评论