Loading file into dictionary splitting into key value pair

  • Thread starter Thread starter Mion Shion
  • Start date Start date
M

Mion Shion

Guest
Hello I am having a problem I have created a dictionary with key-value pairs and successfully saved to text file issue I am having now is I want to edit key-value pairs but don't want to save the whole file each time as there are like 1000 lines

is there any way to save to a file and read certain keys for editing because want to change certain keys after adding keys and pairs to a text file but also need to miss out the first 4 lines because

they are not key-value pairs files I have generated so far

File Saved

and in all this there are 2 weapon files saved one normal one upgraded the revolver is upgraded but the issue im having here is im not sure how to read the file back in and edit only couple of lines

like for example one of the lines i want to add are

ammoName

displayName

on both normal and upgraded i have text boxes in-application and a save button but not sure how to load it up i have tryied the following code

string[] lines = File.ReadAllLines(Application.StartupPath + "\\test.gdt");
var bo3template = lines.Select(l => l.Split(' ')).ToDictionary(a => a[0], a => a[1]);


but the 1st 4 lines ruin it because it's not the part of the key-value pair that is the endient of the file any help would be much appreciated thanks in advance elfenliedtopfan5

Continue reading...
 
Back
Top