Creating JSON file in Universal Windows Application

Hello,

Below is my code for creating a new JSON file in C#.. It gives an error "Object reference not set to an instance of an object.".. What is going wrong?
________________________________________________________________________________________________
Content.data.Add(de);            

string outputJSON = JsonConvert.SerializeObject(Content); //outputJSON is working fine
csfilStorageFile = await csfldrStorFolder.CreateFileAsync(clsDeclarations.gsDataFileName, Windows.Storage.CreationCollisionOption.ReplaceExisting); //The error is caught here

await FileIO.WriteTextAsync(csfilStorageFile , outputJSON);
________________________________________________________________________________________________

Regards.
Soumen RoySenior ManagerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
louisfrConnect With a Mentor Commented:
Maybe csfldrStorFolder or clsDeclarations is null.
0
 
Soumen RoySenior ManagerAuthor Commented:
No, csfldrStorFolder has been created previous to this, the folder is being created. And clsDeclarations holds names for various strings, it exists too. :(
0
 
louisfrCommented:
The StackTrace indicates that line as the source of the exception?
0
 
Soumen RoyConnect With a Mentor Senior ManagerAuthor Commented:
Yes, right on the line I marked as error is caught here.
0
All Courses

From novice to tech pro — start learning today.