Example #1
0
        /// <summary>
        /// Verifies the integrity of the file in the manifest entry.
        /// </summary>
        /// <returns><c>true</c>, if file was complete and undamaged, <c>false</c> otherwise.</returns>
        public bool IsFileIntegrityIntact()
        {
            string LocalPath = String.Format("{0}{1}",
                                             ConfigHandler.Instance.GetGamePath(),
                                             RelativePath);

            if (!File.Exists(LocalPath))
            {
                return(false);
            }
            else
            {
                FileInfo fileInfo = new FileInfo(LocalPath);
                if (fileInfo.Length != Size)
                {
                    return(false);
                }
                else
                {
                    using (Stream file = File.OpenRead(LocalPath))
                    {
                        string localHash = MD5Handler.GetStreamHash(file);
                        if (localHash != Hash)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// Verifies the integrity of the file in the manifest entry.
        /// </summary>
        /// <returns><c>true</c>, if file was complete and undamaged, <c>false</c> otherwise.</returns>
        public bool IsFileIntegrityIntact()
        {
            string localPath = $"{ConfigHandler.Instance.GetGamePath()}{RelativePath}";

            if (!File.Exists(localPath))
            {
                return(false);
            }

            FileInfo fileInfo = new FileInfo(localPath);

            if (fileInfo.Length != Size)
            {
                return(false);
            }

            using (Stream file = File.OpenRead(localPath))
            {
                string localHash = MD5Handler.GetStreamHash(file);
                if (localHash != Hash)
                {
                    return(false);
                }
            }

            return(true);
        }