i m currently working on project doing file management, and i just finish the code for upload file into my database(.mdf) table, however i have no idea how to download the file back to my folder(or anywhere else). I see people do download from ASP.Net, OR web sql database, but i wish if someone could tell me how to download it from a mdf database.
private void find_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
string Path = dlg.FileName.ToString();
PathBox.Text = Path;
PicBox.location = Path;
}
}
private void save_Click(object sender, eventargs e)
{
byte[] Doc = null;
Filestream fs = new FileStream(this.PathBox.Text, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
Doc = br.ReadBytes((int)fs.Length);
string DS = "datasource = localDB ......";
string Insertcmd = "insert into ......";
MySqlConnection conn = new MySqlConnection(DS);
MySqlCommand cmd = new MySqlCommand(Insertcmd, conn);
MySqlDataReader msdr;
try
{
conn.Open();
cmd.Parameter.Add(new MySqlParameter("@Document", Doc));
msdr = cmd.ExecuteReader();
MessageBox.Show("file saved");
While (msdr.Read())
{
}
catch (Exception ex)
{
}
}
could someone give me a code that is able to download from .mdf database? or even any hint will be very helpful
thanks