Search code examples
visual-studioraspberry-piraspberry-pi3windowsiotwindows-iot-core-10

Copy Content Files from VS 2017 to Windows 10 IoT Core for Raspberry Pi 3


I am developing an application for Windows Core for Raspberry Pi 3 using Visual Studio 2017 Community Edition.

I am quite new to the platform and trying to copy some content files to Raspberry. I have tried changing the type of my files to "Content" and "Copy Always" in the property window.

However, I am not able to find where these files are copied and how can I refer these files in my code.

Any help would be greatly appreciated.


Solution

  • However, I am not able to find where these files are copied and how can I refer these files in my code.

    You can get the path like this:

    Windows.Storage.StorageFolder installedLocation = Windows.ApplicationModel.Package.Current.InstalledLocation;
    

    And access these files like this:

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///copyfile test.txt"));
            string text = await Windows.Storage.FileIO.ReadTextAsync(file);
    

    For more information you can reference "File access permissions" and "Create, write, and read a file".