B
Bart
Could someone explain me what is wrong with this code ?
I gives me a compile error:
Error 1 Use of unassigned local variable 'fileStreamObject' C:\Documents and
Settings\Bart\Local Settings\Application Data\Temporary
Projects\WindowsApplication1\employeeReader.cs 22 17 WindowsApplication1
The code is:
public void Write(string filename, Employee emp)
{
FileStream fileStreamObject;
try
{
fileStreamObject = new FileStream(filename,
FileMode.Create);
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(fileStreamObject, emp);
}
finally
{
fileStreamObject.Close(); <-------- gives an error !!!
}
}
Thanks a lot
Bart
I gives me a compile error:
Error 1 Use of unassigned local variable 'fileStreamObject' C:\Documents and
Settings\Bart\Local Settings\Application Data\Temporary
Projects\WindowsApplication1\employeeReader.cs 22 17 WindowsApplication1
The code is:
public void Write(string filename, Employee emp)
{
FileStream fileStreamObject;
try
{
fileStreamObject = new FileStream(filename,
FileMode.Create);
BinaryFormatter binaryFormatter = new BinaryFormatter();
binaryFormatter.Serialize(fileStreamObject, emp);
}
finally
{
fileStreamObject.Close(); <-------- gives an error !!!
}
}
Thanks a lot
Bart
