private void saveStudent<T>(string filePath, T objectToWrite)
{
stream = File.OpenWrite(filePath); **//Error is here**
var binaryData = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryData.Serialize(stream, objectToWrite);
stream.Close();
}