Example #1
0
        public static async Task Download(ShareFileClient sfClient, Item itemToDownload)
        {
            var downloadDirectory = new DirectoryInfo("DownloadedFiles");

            if (!downloadDirectory.Exists)
            {
                downloadDirectory.Create();
            }

            var downloader = sfClient.GetAsyncFileDownloader(itemToDownload);
            var file       = System.IO.File.Open(Path.Combine(downloadDirectory.Name, itemToDownload.Name), FileMode.Create);

            await downloader.DownloadToAsync(file);
        }
        public static async Task Download(Item itemToDownload, string destinationDownloadFolder)
        {
            var downloadDirectory = new DirectoryInfo(destinationDownloadFolder);

            if (!downloadDirectory.Exists)
            {
                downloadDirectory.Create();
            }

            var downloader = sfClient.GetAsyncFileDownloader(itemToDownload);
            var file       = System.IO.File.Open(Path.Combine(downloadDirectory.Name, itemToDownload.Name), FileMode.Create);

            await downloader.DownloadToAsync(file);
        }