.txt文件在哪里保存Xamarin.Forms

时间:2018-11-15 10:48:47

标签: c# xamarin xamarin.forms

此代码正确运行。但是我不知道我的.txt文件保存在哪里

public string PersonalFolderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

//Write Information to a Local File
public void WriteLocalFile(string FileName, string Data)
{
    string filePath = Path.Combine(PersonalFolderPath, FileName);
    File.WriteAllText(filePath, Data);
}
//Load Information from a Local File
public string LoadLocalFile(string FileName)
{
    string filePath = Path.Combine(PersonalFolderPath, FileName);
    if (File.Exists(filePath))
    {
        showtext.Text= File.ReadAllText(filePath);
        return showtext.Text;
    }
    return null;
}

private void SaveButton_Clicked(object sender, EventArgs e)
{
    WriteLocalFile("Burak.txt", text.Text);
}

private void LoadButton_Clicked(object sender, EventArgs e)
{
    LoadLocalFile("Burak.txt");
}

如何找到它?还是另一种方式? 谢谢。

1 个答案:

答案 0 :(得分:0)

对于iOS:

模拟器:

获得filePath后,您可以转到Finder->选择Go->选择Go To Folder...,然后输入filePath。单击Go,您可以在该文件夹中获取文档。

电话:

您可以通过手机的下载容器查看文档。您可以参考There's a way to access the document folder in iphone/ipad (real device, no simulator)?