예제 #1
0
        /// <summary>
        /// 版本检查
        /// </summary>
        /// <returns></returns>
        private bool checkVersionForRelease(ref string version)
        {
            string localpath =
                Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "version.ini");

            if (!File.Exists(localpath))
            {
                return(false);
            }
            byte[] content = null;
            ReadFile(out content, localpath);
            if (content != null)
            {
                string localversion = System.Text.Encoding.Default.GetString(content);
                NCFTP  ftp          = new NCFTP();
                if (ftp.download(Path.Combine(upgradeurl, "version.ini"), @"c:\cjw\version.ini", userName, password))
                {
                    ReadFile(out content, @"c:\cjw\version.ini");
                    string remoteversion = System.Text.Encoding.Default.GetString(content);

                    if (float.Parse(remoteversion) < float.Parse(localversion))
                    {
                        version = localversion;
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #2
0
        /// <summary>
        /// 下载ZIP文件
        /// </summary>
        private void downloadZipFile(string version)
        {
            string path    = Path.GetDirectoryName(Application.ExecutablePath);
            string zipname = Path.Combine(path, version + Path.GetFileName(fileName));
            string url     = Path.Combine(upgradeurl, Path.GetFileName(zipname));
            NCFTP  ftp     = new NCFTP();

            ftp.download(url, zipname, userName, password);
        }
예제 #3
0
        /// <summary>
        /// 文件下载
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        private bool downloadFile(string file)
        {
            NCFTP  ftp = new NCFTP();
            string src = Path.GetFileName(file);

            if (ftp.download(Path.Combine(ftpserver, src), file, userName, password))
            {
                return(true);
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// 取得要下载文件列表
        /// </summary>
        /// <returns></returns>
        private string[] getFileListFromFtp()
        {
            byte[] content = null;
            NCFTP  ftp     = new NCFTP();

            if (ftp.download(Path.Combine(ftpserver, remote_file), local_file, userName, password))
            {
                ReadFile(out content, local_file);
                string   remotefilelist = System.Text.Encoding.Default.GetString(content);
                string[] files          = remotefilelist.Split(';');
                return(files);
            }
            return(null);
        }
예제 #5
0
        /// <summary>
        /// 文件一览更新
        /// </summary>
        /// <param name="file"></param>
        private void updateFilelist(string file)
        {
            byte[] content = null;
            NCFTP  ftp     = new NCFTP();

            if (ftp.download(Path.Combine(ftpserver, remote_file), local_file, userName, password))
            {
                ReadFile(out content, local_file);
                string remotefilelist = System.Text.Encoding.Default.GetString(content);
                remotefilelist += ";" + Path.GetFileName(file);
                WritetoFile(System.Text.Encoding.Default.GetBytes(remotefilelist), local_file);
                ftp.uploadFile(Path.Combine(ftpserver, remote_file), local_file, userName, password);
            }
            else
            {
                WritetoFile(System.Text.Encoding.Default.GetBytes(Path.GetFileName(file)), file);
                ftp.uploadFile(Path.Combine(ftpserver, remote_file), local_file, userName, password);
            }
        }