Runtime error Attempting to deserialize an empty stream
问题 I am trying to deserialize an list of string from a file. Here my code FileStream filestream = new FileStream(@"D:\cache.bin", FileMode.OpenOrCreate); try { BinaryFormatter binformat = new BinaryFormatter(); _cacheFileList = (List<string>)binformat.Deserialize(filestream); } catch (SerializationException ex) { Console.WriteLine(ex.Message); } finally { filestream.Close(); } I am getting a Runtime error. Attempting to deserialize an empty stream. 回答1: If you want support for empty files, first