46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Threading.Tasks;
|
||
|
using System.IO;
|
||
|
using Timelapse.Api;
|
||
|
namespace Timelapse.Data
|
||
|
{
|
||
|
public class RecentFileService
|
||
|
{
|
||
|
public static RecentFileService RFS;
|
||
|
public static string RecentFile=Path.Combine(Extensions.UserData,"recent.txt");
|
||
|
public RecentFileService()
|
||
|
{
|
||
|
|
||
|
if(File.Exists(RecentFile))
|
||
|
{
|
||
|
Files = File.ReadAllLines(RecentFile).ToList();
|
||
|
}else{
|
||
|
Files = new List<string>();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
public void Add(string file)
|
||
|
{
|
||
|
if(Files.Contains(file))
|
||
|
{
|
||
|
Files.Remove(file);
|
||
|
}
|
||
|
Files.Add(file);
|
||
|
File.WriteAllLines(RecentFile,Files);
|
||
|
|
||
|
}
|
||
|
static List<string> Files;
|
||
|
|
||
|
public Task<RecentFile[]> GetRecentFilesAsync()
|
||
|
{
|
||
|
var rng = new Random();
|
||
|
return Task.FromResult(Files.Select(name => new RecentFile
|
||
|
{
|
||
|
Fullpath=name
|
||
|
}).ToArray());
|
||
|
}
|
||
|
}
|
||
|
}
|