我希望能够使用Android的内部存储。我发现了一些代码片段,例如:
string path = Application.Context.FilesDir.Path;
var filePath = Path.Combine(path, "test.txt");
System.IO.File.WriteAllText(filePath, "Hello World");
但是我不知道这里有什么应用程序。
有没有针对该观点或不同观点的解决方案?谢谢 :)
用这个:
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);
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句