使用 Windows IoT 在 Raspberry PI 上保存文件 [英] Saving files on Raspberry PI with Windows IoT

查看:24
本文介绍了使用 Windows IoT 在 Raspberry PI 上保存文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于使用 Windows IoT 在 Raspberry PI 上保存文件的问题.

I have a question about saving files on Raspberry PI with Windows IoT.

我想做什么:我有各种想要记录的值(温度).对我来说,最简单的方法是编写一个包含所有值的简单 txt 文件.

What I want to do: I have various values (temperature) which I want to log. The easiest way for me would be, to write a simple txt-file with all the values.

首先:是否可以在本地创建 SD 卡上的文件?因为我发现的代码示例仅适用于普通"Windows 系统:

First of all: Is it even possible to create a file locally on the SD card? Because the code samples I found only work on a "normal" Windows system:

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

或在 Windows Phone 上:

or on 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 时,我也找不到目录.

The code for Windows Phone makes more sense to me. (The other doesn't work at all anyway). But even the phone code is the correct one, I have no idea how to get an access to the internal storage. I've tried the IsolatedStorageExplorerTool, but it doesn't recognize my device. Probably because my device is not connected with USB... and it's not a phone. When I use SSH I also can't find the directory.

也许有人有想法.在此先感谢您的帮助!

Maybe someone has an idea. In advance thanks for your help!

推荐答案

没关系,我找到了解决方案.1.这是Windows手机的代码.2. 您必须使用 Windows IoT Core Watcher.右键单击您的设备并打开网络共享.之后我在以下位置找到了文本文件:\c$UsersDefaultAccountAppDataLocalPackages\LocalStateTextFilesFolder

Nevermind, I found the solution. 1. It's the code for Windows phone. 2. You have to use the Windows IoT Core Watcher. Right click on your device and open the network share. Afterwards I found the text file at: \c$UsersDefaultAccountAppDataLocalPackages\LocalStateTextFilesFolder

这篇关于使用 Windows IoT 在 Raspberry PI 上保存文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆