private static StorageFolder GetStorageFolder(string folderName) { //var folder = Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDownloads).AbsolutePath; var folder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var desktop = new StorageFolder { FolderName = folder }; var sf = DownloadHelper.GetFolder(desktop, "MS.Video.Downloader"); return DownloadHelper.GetFolder(sf, folderName); }
public static StorageFile GetFile(StorageFolder folder, string fileName) { return new StorageFile {StorageFolder = folder, FileName = fileName}; }
public static StorageFolder GetFolder(StorageFolder baseFolder, string folderName) { if (!Directory.Exists(baseFolder.ToString())) Directory.CreateDirectory(baseFolder.ToString()); var path = baseFolder + "/" + folderName; if(!Directory.Exists(path)) Directory.CreateDirectory(path); return new StorageFolder(path); }
public static void DownloadToFileAsync(YoutubeEntry entry, Uri uri, StorageFolder folder, string fileName, MSYoutubeLoading onYoutubeLoading) { if (entry.ExecutionStatus != ExecutionStatus.Normal) return; var storageFile = GetFile(folder, fileName); using (var destinationStream = storageFile.OpenStreamForWriteAsync()) { if (destinationStream == null) return; //var properties = await storageFile.GetBasicPropertiesAsync(); var start = destinationStream.Length; // (long)properties.Size; destinationStream.Position = destinationStream.Length; AddToFile(entry, uri, destinationStream, start, start + BlockSize - 1, onYoutubeLoading); } }
public static bool FileExists(StorageFolder folder, string videoFile) { var file = new StorageFile {StorageFolder = folder, FileName = videoFile}; return File.Exists(file.ToString()); }