If i make a Stream object to open a text file with OpenFileDialog, in what scope should i close it? In the same scope were i declared it, or inside one of the ifs (to close it just in the case that it opened properly)?.
I leave you the code here so you can tell me...
Stream arch_Usuarios; OpenFileDialog openFileDialog_arch_Usuarios = new OpenFileDialog(); if (openFileDialog_arch_Usuarios.ShowDialog() == DialogResult.OK) { if ((arch_Usuarios = openFileDialog_arch_Usuarios.OpenFile()) != null) { ... } } Greetings.
usingstatement. That should solve this problem.nullor an uninitialized stream, but an exception.Abc_Defstyle