Emr*_*gül 3 storage android internal xamarin
我希望能够使用Android的内部存储.我找到了一些代码片段,如:
string path = Application.Context.FilesDir.Path;
var filePath = Path.Combine(path, "test.txt");
System.IO.File.WriteAllText(filePath, "Hello World");
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚应用程序在这里.
对于那个或不同的观点有什么解决方案吗?谢谢 :)
用这个:
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);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7014 次 |
| 最近记录: |