FileIO类配置及初始化:
private StorageFile samplie;
StorageFolder folder = ApplicationData.Current.LocalFolder;//获取应用文件目录
public string file_name = "Quene.sisx";
向队列中添加数据:(以回车作为分割符)
public async void AddQuene(string Info)
{
StorageFile file = await folder.GetFileAsync(file_name);
if (file != null)
{
try
{
string Str = await Windows.Storage.FileIO.ReadTextAsync(file);
await Windows.Storage.FileIO.WriteTextAsync(file, Str+Info+"\n");
}
catch (Exception)
{ }
}
}
读取队列中的数据,并在读取后清空队列
public async void PoPOut()
{
try
{
StorageFile file = await folder.GetFileAsync(file_name);
string Str = await Windows.Storage.FileIO.ReadTextAsync(file);
Quene = Str.Split(Environment.NewLine.ToCharArray());
await Windows.Storage.FileIO.WriteTextAsync(file, "");//清空数据栈
}
catch (Exception)
{
}
}