Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have saved a list of JSON files stored in a local folder. What I've been trying to do is to view all those JSON files to a listbox then auto populate the JSON file selected in a series of textfields for each attribute.

Here are the contents of each JSON FILES and they are saved in a specific folder inside the jsonlibrary where the project is saved.

{ "FirstName": "Allen", "LastName": "Lex", "Email": "allen.lex", "TeamName": "Allen Lex", "Password": "allen123", "IsActive": "Yes", "UserId": 15 }
{ "FirstName": "Eddie", "LastName": "Chavo", "Email": "eddie.chavo", "TeamName": "Eddie Chavo", "Password": "eddie123", "IsActive": "Yes", "UserId": 120 }



I'm kinda new to c# and JSON files at the same time. Anyone can help me with this? Thanks a lot!

What I have tried:

Here's also my code in adding/creating a JSON file and save it to the folder:


string isActive = chkIsActive.Checked ? "Yes" : "No";
var account = new UserAccount()
{
FirstName = txtFirstName.Text,
LastName = txtLastName.Text,
Email = txtEmail.Text,
TeamName = txtTeamName.Text,
Password = txtPassword.Text,
IsActive = isActive,
UserId = int.Parse(txtUserId.Text)
};
string jsonFilePath = $@"{Environment.CurrentDirectory}\Output\" + txtFirstName.Text + " " + txtLastName.Text + ".json";
JsonMgr.SerializeObj_ToFile<UserAccount>(account, jsonFilePath);
MessageBox(.)Show("Successfully added new record", "Added user", MessageBoxButtons.OK, MessageBoxIcon.Information);
Posted
Comments
CoderzF1 15-Aug-22 18:21pm    
Are you wanting to load the contents of the files into a listbox or are you wanting to just show a list of the files in the listbox?
CoderzF1 15-Aug-22 18:23pm    
Also, I do hope you are not storing User's passwords in plain text like this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900