Suppose structured
public struct stStaff
{
public WhatType? Picture; // Pictures 3x4 (what kind for pictures ?)
public string FullName; // FullName
public DateTime BirthDay; // Birthday
}
Can save images to a structured text file (note: do not store the path of the image), to save the image of the structure of text files will have style? one example of this?
Loading

VulpesRank #55 · 29.2K reputationPosted Oct 19, 2012, 12:53 AM EDT
http://www.codeproject.com/Articles/15460/C-Image-to-Byte-Array-and-Byte-Array-to-Image-Conv
Dong Lam TrienRank #1,538 · 1K reputationPosted Nov 21, 2012, 5:27 PM EST
in my save button code
Path = @"C:\data\database.dat"; FileStream fs; try { fs = new FileStream(path, FileMode.Create); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); return; } BinaryWriter bw = new BinaryWriter(fs); Staff = new Staff(); Staff.Picture = (Bitmap)pictureBox1.Image; Staff.FullName = txtFullName.Text; Staff.BirthDay = DateTime.Parse(mskNgaysinh.Text); //ClsStaff Staff; // Save for (int i = 0; i // warning error: The best overloaded method match for //'System.IO.BinaryWriter.Write(bool)' has some invalid arguments bw.Write(Staff.FullName); bw.Write(Staff.BirthDay.ToBinary()); } bw.Flush(); bw.Close(); fs.Close();bw.Write(Staff.Picture); // warning error: The best overloaded method match for 'System.IO.BinaryWriter.Write(bool)' has some invalid arguments
I wonder in the text file can save the Bitmap type? or to switch to the new chain store? if it is correct on how?
VulpesRank #55 · 29.2K reputationPosted Nov 22, 2012, 1:53 AM EST
However, you can't use BinaryWriter to write a Bitmap directly to a file.
You have to convert the Bitmap to a byte array first and then write that to the file. There is an overload of the Write method which takes a byte array as a parameter:
http://msdn.microsoft.com/en-us/library/bx149a0k.aspx