Пример #1
0
        /// <summary>
        /// Download model file
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="fileName"></param>
        public static void DownloadAndSave(Uri uri, string fileName)
        {
            if (File.Exists(fileName))
            {
                return;
            }

            var bytes = FileDownloader.DownloadData(uri);

            File.WriteAllBytes(fileName, bytes);
        }
Пример #2
0
        /// <summary>
        /// Download model file if it does not exist on local disk
        /// </summary>
        /// <param name="uri"></param>
        /// <param name="fileName"></param>
        private void PrepareModel(Uri uri, string fileName)
        {
            lock (lockObj)
            {
                if (File.Exists(fileName))
                {
                    return;
                }

                var contents = FileDownloader.DownloadData(uri);
                File.WriteAllBytes(fileName, contents);
            }
        }
 private static void PrepareModel(string fileName)
 {
     lock (lockObj)
     {
         if (!File.Exists(fileName))
         {
             var contents = FileDownloader.DownloadData(new Uri(ModelUrl));
             using var srcStream  = new MemoryStream(contents);
             using var gzipStream = new GZipStream(srcStream, CompressionMode.Decompress);
             using var dstStream  = new MemoryStream();
             gzipStream.CopyTo(dstStream);
             File.WriteAllBytes(fileName, dstStream.ToArray());
         }
     }
 }