Search code examples
jsonuwptemplate10filepicker

Reading Values from Known file located on system


I'm new to Stack Overflow, otherwise I would have commented to the primary question in this post...

UWP apps accessing files from random location on system

My situation is similar, but different. It seems that in the post above, that they are trying to read values from a file selected by the user via file picker.

Where I differ is I would like to read a file created my SCCM team, stored on every computer within company. This file will have values like HD Serial Number and Windows Creation date. (values that I can not easily read without doing something like Windows Brokered Component). [Good article here if anyone interested]

Since I know the path of file ahead of time, I'm hoping I can just do like so...
(not on my VS2015 pc, pardon my hacked logic... Hopefully my answers will magically come back in Cut&Paste code ;-))

if 
    file exist within %localappdata%\MyAppName\ImportedValues.JSON
else
    Open FilePicker (location of PowerShellScript that will rerun creation of JSON file)

JSON File Sample

{  
    "Hardware": {  
        "TerminalID": "NameOfThisComputer",  
        "HardDriveSN": "111111111",  
        "HardDriveModel": "SamsungSSD",  
        "StagingStartDate": "Thursday, September 17, 2009 3:58:54 PM"  
    }  
}

Solution

  • Your UWP app doenst have access to read any file on the computer. SO they have to place it in the appdata folder as you can find here: http://caioproiete.net/en/physical-location-of-windows-store-applications-and-data-on-a-pc/

    or it need to be opened via filepicker.