我有一个关于使用 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/