如何在Xamarin中使用Android的内部存储?

时间:2016-06-28 12:07:51

标签: android xamarin storage internal

我希望能够使用Android的内部存储空间。我找到了一些代码片段,如:

@Rollback(true)

但我无法弄清楚应用程序在这里。

对于那个或不同的观点有没有解决方案? 谢谢:))

1 个答案:

答案 0 :(得分:6)

使用此:

string path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal);
string filename = System.IO.Path.Combine(path, "testfile.txt");

// Write
using (var streamWriter = new StreamWriter(filename, true))
{
    streamWriter.WriteLine(DateTime.UtcNow);
}

// Read
using (var streamReader = new StreamReader(filename))
{
    string content = streamReader.ReadToEnd();
    System.Diagnostics.Debug.WriteLine(content);
}
相关问题