示例#1
0
        public static async Task DeleteFile(DMM m)
        {
            try
            {
                StorageFolder guidFolder = await DownFolder.CreateFolderAsync("GUID", CreationCollisionOption.OpenIfExists);

                await(await guidFolder.GetFileAsync(m.guid + ".json")).DeleteAsync();



                StorageFolder videoFolder = await StorageFolder.GetFolderFromPathAsync(m.folderPath);

                await videoFolder.DeleteAsync();

                //folderList.Remove(folderList.First(x => x.id == m.folderinfo.id));
                //await SetfolderList();
                //var file = await videoFolder.GetFileAsync(m.videoinfo.downGUID + ".json");
                //string filedata = await FileIO.ReadTextAsync(file);
                //GuidModel gm = JsonConvert.DeserializeObject<GuidModel>(filedata);
                //var fo = await StorageFolder.GetFolderFromPathAsync(gm.path);
                //await fo.DeleteAsync(StorageDeleteOption.Default);
                //await file.DeleteAsync(StorageDeleteOption.Default);
            }
            catch (Exception ex)
            {
                await new MessageDialog("删除文件失败\r\n" + ex.Message).ShowAsync();
            }
        }
示例#2
0
        public static async Task <List <DM> > GetDownEedList()
        {
            List <DM> ls = new List <DM>();

            try
            {
                downMids.Clear();
                StorageFolder ds;
                if (SettingHelper.Get_CustomDownPath() && SettingHelper.Get_DownPath() != "系统视频库")
                {
                    string mruFirstToken = StorageApplicationPermissions.MostRecentlyUsedList.Entries.First(x => x.Metadata == SettingHelper.Get_DownPath()).Token;
                    var    settingFolder = await StorageApplicationPermissions.MostRecentlyUsedList.GetFolderAsync(mruFirstToken);

                    ds = await settingFolder.CreateFolderAsync("BiliVideoDownload", CreationCollisionOption.OpenIfExists);
                }
                else
                {
                    ds = await KnownFolders.VideosLibrary.CreateFolderAsync("BiliVideoDownload", CreationCollisionOption.OpenIfExists);
                }
                try
                {
                    foreach (var item in await ds.GetFoldersAsync())
                    {
                        DM dm = new DM();

                        dm.id = item.Name;
                        //BitmapImage bm = new BitmapImage();
                        //bm.SetSource((await item.GetThumbnailAsync(Windows.Storage.FileProperties.ThumbnailMode.PicturesView)).CloneStream());
                        // dm.img = bm;
                        dm.path = item.Path;
                        var ll = new List <DMM>();
                        try
                        {
                            foreach (var item1 in await item.GetFoldersAsync())
                            {
                                var d     = new DMM();
                                var files = await item1.GetFilesAsync();

                                foreach (var item2 in files)
                                {
                                    try
                                    {
                                        if (item2.FileType == ".json")
                                        {
                                            string json = await FileIO.ReadTextAsync(item2);

                                            var vm = JsonConvert.DeserializeObject <VideoListModel>(json);
                                            d.path = item2.Path;
                                            d.name = vm.title + "-" + vm.partTitle;
                                            d.aid  = vm.id;
                                            d.mid  = vm.mid;
                                            downMids.Add(d.mid, item1.Path);
                                            d.folderPath = item1.Path;
                                            d.guid       = vm.downGUID;
                                            if (d.aid.Length <= 5)
                                            {
                                                d.isbangumi = true;
                                            }
                                            else
                                            {
                                                d.isbangumi = false;
                                            }
                                        }
                                        if (item2.FileType == ".xml")
                                        {
                                            d.dmPath = item2.Path;
                                        }
                                        if (item2.FileType == ".mp4" && (await item2.GetBasicPropertiesAsync()).Size != 0)
                                        {
                                            ll.Add(d);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                        dm.videos = ll;
                        if (dm.videos.Count != 0)
                        {
                            ls.Add(dm);
                        }
                    }
                }
                catch (Exception ex)
                {
                }


                return(ls);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(ls);
            }
        }