我对使用Windows IoT在Raspberry PI上保存文件有疑问。

我想做的事:
我有多个要记录的值(温度)。对我而言,最简单的方法是编写一个包含所有值的简单txt文件。

首先:甚至可以在SD卡上本地创建文件吗?因为我发现的代码示例仅在“正常” Windows系统上工作:

        if (!File.Exists(path))
    {
        // Create a file to write to.
        string createText = "Hello and Welcome" + Environment.NewLine;
        File.WriteAllText(path, createText);
    }

或在Windows Phone上:
      public void createdirectory()
    {
        IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
        myIsolatedStorage.CreateDirectory("TextFilesFolder");
        filename = "TextFilesFolder\\Samplefile.txt";
        Create_new_file();
    }

    public void Create_new_file()
    {
        IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();

        if (!myIsolatedStorage.FileExists(filename))
        {
            using (StreamWriter writeFile = new StreamWriter(new IsolatedStorageFileStream(filename, FileMode.Create, FileAccess.Write, myIsolatedStorage)))
            {
                string someTextData = "This is a test!";
                writeFile.WriteLine(someTextData);
               // writeFile.Close();
            }
        }

Windows Phone的代码对我来说更有意义。 (另一个根本不起作用)。但是,即使电话代码是正确的代码,我也不知道如何访问内部存储。我已经尝试过IsolatedStorageExplorerTool,但无法识别我的设备。可能是因为我的设备未与USB连接...而且它不是手机。当我使用SSH时,我也找不到目录。

也许有人有一个主意。预先感谢您的帮助!

最佳答案

没关系,我找到了解决方案。
1.这是Windows Phone的代码。
2.您必须使用Windows IoT核心监视程序。右键单击您的设备,然后打开网络共享。之后,我在以下位置找到了文本文件:
\\ c $ \ Users \ DefaultAccount \ AppData \ Local \ Packages \\ LocalState \ TextFilesFolder

10-07 14:05
查看更多