Недопустимый двоичный формат входного потока - C#
Формулировка задачи:
Всем привет! Возникла такая ошибка: "Недопустимый двоичный формат входного потока."
В чем может быть проблема? Вот код:
Листинг программы
- namespace pr
- {
- [Serializable]
- class logic
- {
- StringBuilder organisation;
- StringBuilder telephone;
- StringBuilder contact;
- StringBuilder adress;
- public logic()
- {
- organisation = new StringBuilder("ГАЗПРОМ", 80);
- adress = new StringBuilder("улица Руставелли",100);
- telephone = new StringBuilder("88006005050", 11);
- contact = new StringBuilder("www.bbb.com", 100);
- }
- public logic(string organisation, string adress, string telephone, string contact)
- {
- this.organisation = new StringBuilder(organisation, 80);
- this.adress = new StringBuilder(adress, 100);
- this.telephone = new StringBuilder(telephone, 11);
- this.contact = new StringBuilder(contact, 100);
- }
- public void AddToFile(string path)
- {
- FileStream f = new FileStream(path, FileMode.Append);
- BinaryFormatter bw = new BinaryFormatter();
- bw.Serialize(f, this, null);
- f.Close();
- }
- public static string Show(string path)
- {
- BinaryFormatter formatter = new BinaryFormatter();
- string ans = "";
- using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
- {
- while (fs.Position < fs.Length)
- {
- logic newLogic = (logic)formatter.Deserialize(fs);
- ans += newLogic.organisation + "," +newLogic.adress+","+ newLogic.telephone + "," + newLogic.contact + "," + "";
- }
- }
- return ans;
- }
- public long find(string path)
- {
- BinaryFormatter formatter = new BinaryFormatter();
- using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
- {
- while (fs.Position < fs.Length)
- {
- long pos = fs.Position;
- logic newLogic = (logic)formatter.Deserialize(fs);
- if (newLogic.organisation.Equals(this.organisation))
- return pos;
- }
- }
- return -1;
- }
- public void correct(string path, long pos)
- {
- BinaryFormatter formatter = new BinaryFormatter();
- using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate))
- {
- fs.Seek(pos, SeekOrigin.Begin);
- formatter.Serialize(fs, this, null);
- }
- }
- }
- }
Решение задачи: «Недопустимый двоичный формат входного потока»
textual
Листинг программы
- for (int i = 0; i < b.Length; i++)
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д