I have a question about saving files on Raspberry PI with Windows IoT.
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.
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);
}
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();
}
}
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!
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$\Users\DefaultAccount\AppData\Local\Packages\\LocalState\TextFilesFolder