I have a settings.json file present in the Release folder of my application. What I want to do is change the value of it, not temporarily, permanently.. That means, deleting
I have been able to use the info above to get 2/3rds of my program working. I am updating three values.
.json format snippet:
{ "Version": "1.0.0", "SignBatches": [ { "SourceRootDirectory": "c:\red", "DestinationRootDirectory": "d:\green", "SignRequestFiles": [ { "SourceLocation": "billboard-GS_PariahHeart-v1.lzp" } ],
Code that works:
jsonObj["SignBatches"][0]["SourceRootDirectory"] = Path.GetDirectoryName(args[0]);
jsonObj["SignBatches"][0]["DestinationRootDirectory"] = Path.GetDirectoryName(args[1]);
Code that fails:
jsonObj["SignRequestFiles"][0]["SourceLocation"] = Path.GetFileName(args[0]);
Note that this is trying to update a value of a nested object in the .json file. the previous two lines are updating a similar value, but they are at the top level.
The error generated is:
Unhandled exception. Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot perform runtime binding on a null reference