Пример #1
0
        public void GetMD5ForFileTest()
        {
            string fileName = AppDomain.CurrentDomain.BaseDirectory + "\\MD5 test.txt"; // TODO: Initialize to an appropriate value
            string expected = "E26AC8BB85B704AC5F85DEA83A5ED99B";                       // TODO: Initialize to an appropriate value
            string actual;

            actual = MD5Maker.GetMD5ForFile(fileName);
            Assert.AreEqual(expected, actual);
        }
Пример #2
0
        /// <summary>
        /// Updater a file via Downloader class
        /// </summary>
        /// <param name="updateFileName">The file want to update without the path</param>
        /// <param name="md5InServer">The md5 value from DFUpdateInstruction.xml</param>
        /// <returns>Updater result: True-success; False-failed</returns>
        private bool DoUpdate(string updateFileName, string md5InServer)
        {
            string fullFileName = this.GetFullFileName(this.FileLocalPath, updateFileName);
            string url          = this.GetFullFileName(this.FileServerPath, updateFileName);
            bool   isUpdated    = false;
            string md5InLocal   = string.Empty;

            if (File.Exists(fullFileName))
            {
                md5InLocal = MD5Maker.GetMD5ForFile(fullFileName);
                if (md5InLocal != md5InServer)
                {
                    isUpdated = HttpUtils.DownloadFile(url, fullFileName);
                }
            }
            else
            {
                isUpdated = HttpUtils.DownloadFile(url, fullFileName);
            }

            return(isUpdated);
        }