c# - 使用 Windows IoT 在 Raspberry PI 上保存文件

标签 c# raspberry-pi windowsiot

我有一个关于使用 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 Core Watcher。右键单击您的设备并打开网络共享。后来我在以下位置找到了文本文件: \\c$\Users\DefaultAccount\AppData\Local\Packages\\LocalState\TextFilesFolder

关于c# - 使用 Windows IoT 在 Raspberry PI 上保存文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34385625/

相关文章:

c++ - 由于外部依赖性,StartupTask.cpp 构建失败

c# - 不同的列表列表,其中列表包含相同的值但顺序不同

c# - 如何在 C# 中使用 zxing 应用 Reed-Solomon 算法

c++ - 从 C++ Qt 应用程序中的 python 脚本读取输出

javascript - 为什么我的 Raspberry 数字标牌解决方案不能正常工作?

c# - 如何使用Windows IOT获取Raspberry PI 2的处理器序列号

c# - c# 中的链表和红/黑树 - 引用问题?

c# - MySQL 连接时间太长?

linux - 在 x86 上为 ARM 构建 opencv 应用程序

protocols - 适用于 Windows IOT Core 的 MQTT 代理?