Пример #1
0
        /// <summary>
        /// Downloads all required files using asynchoronous operations.
        /// </summary>
        /// <exception cref="WebException"></exception>
        /// <exception cref="ArgumentException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="InvalidDataContractException"></exception>
        /// <exception cref="SerializationException"></exception>
        public void DownloadUpdate()
        {
            if (!updInfo.Loaded)
            {
                throw new ArgumentException("Error: attempting to download update whereas no update information available");
            }

            int filesCount = updInfo.FilePath.Length == updInfo.FileURL.Length ? (updInfo.FileURL.Length == updInfo.MD5.Length ? updInfo.MD5.Length : 0) : 0;

            if (filesCount == 0)
            {
                throw new ArgumentException("Error: update information is corrupted or incomplete");
            }

            using (FileStream fs = new FileStream(updateInfoFilePath, FileMode.Create))
            {
                jsonSerializer.WriteObject(fs, updInfo);
                fs.Flush();
            }

            wipCount = filesCount;
            for (int i = 0; i < filesCount; ++i)
            {
                WC.DownloadDataAsync(new Uri(rawUrl + updInfo.FileURL[i]), i);
            }
        }