In that case, when I want to save and extract all types of files in MS SQL SERVER 2008, I can save and get any file, but without the extension. For example, if I save the xyz.txt file in the database, when I extract it to the local disk, it looks like xyz, without the extension, and yes, if we give the extension manually, then we can see its contents.
Next image of my table

C # code to save any type of file in a database
private void cmdSave_Click(object sender, EventArgs e)
{
try
{
byte[] FileData = ReadFile(txtFilePath.Text);
SqlConnection CN = new SqlConnection(txtConnectionString.Text);
string qry = "insert into FilesStore (OriginalPath,FileData) values(@OriginalPath, @FileData)";
SqlCommand SqlCom = new SqlCommand(qry, CN);
SqlCom.Parameters.Add(new SqlParameter("@OriginalPath", (object)txtFilePath.Text));
SqlCom.Parameters.Add(new SqlParameter("@FileData", (object)FileData));
CN.Open();
SqlCom.ExecuteNonQuery();
CN.Close();
this.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
C # code to extract a file from a database to a local disk
private void btnSaveFromDBToDisk_Click(object sender, EventArgs e)
{
try
{
if (dataGridView1.CurrentCell ==null)
{
MessageBox.Show("Select a file in Grid first.");
return;
}
int SelectedRow = dataGridView1.CurrentCell.RowIndex;
string OriginalPath = DS.Tables[0].Rows[SelectedRow]["OriginalPath"].ToString();
saveFileDialog1.FileName = OriginalPath;
DialogResult DR = saveFileDialog1.ShowDialog();
if (DR == DialogResult.OK)
{
string FileName = saveFileDialog1.FileName;
byte[] FileData = (byte[])DS.Tables["FilesStore"].Rows[SelectedRow]["FileData"];
using (FileStream fs = new FileStream(FileName, FileMode.Create))
{
fs.Write(FileData, 0, FileData.Length);
fs.Close();
}
MessageBox.Show("File saved successfully to ");
}
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
An image of how this project works.
http://i.stack.imgur.com/dqYMe.jpg

http://www.shabdar.org/sql-server/121-store-or-save-files-in-sql-server-database-using-c.html