0

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"  
    }  
}
Community
  • 1
  • 1
ekgcorp
  • 165
  • 1
  • 11

1 Answers1

0

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.

Dave Smits
  • 1,871
  • 14
  • 22
  • So I would have to install the app first, then have JSON file populated with Values, and added to %USERPROFILE%\AppData\Local\Packages\{PackageId}\LocalState later.. Then I could just change my IF references inside of application to ApplicationData.Current.LocalFolder\ImportedValues.JSON? – ekgcorp Feb 09 '17 at 17:12
  • that would be correct there is a whole bunch of folders there you could even do it in the Roaming folder... – mvermef Feb 09 '17 at 20:21