>>100142847
private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
text = File.ReadAllText(@openFileDialog.FileName);
}
if (!string.IsNullOrWhiteSpace(text)){
openFileToolStripMenuItem.Enabled = false;
closeFileToolStripMenuItem.Enabled = true;
btn_editFile.Enabled = true;
status_label_filename.Text = openFileDialog.FileName;
records = JsonSerializer.Deserialize<List<Records>>(text, opt);
lstbx_records.Items.Clear();
foreach (var record in records)
{
Console.WriteLine($"Creation Date: {record.CreationDate}"); // Use nullable conditional operator for safety
Console.WriteLine($"Last Update: {record.LastUpdateDate}"); // Use nullable conditional operator for safety
Console.WriteLine("Amount is {0} and type is {1}", record.Name, record.Url);
lstbx_records.Items.Add(record.Name);
}
}
openFileDialog.Dispose();
System.GC.Collect();
//Console.WriteLine("GC CHIAMATA!");
}
I fixed the code like this... This time the dll is loaded only if I select a file. But when I open it allocates the memory, but when I close by canceling the operation it doesn't free it as it was at the beginning... No other module is called upon opening...