展开全部
向数据库中保存不同类型的文件,和在数据库中保存图e69da5e887aa3231313335323631343130323136353331333337613164片是一样的。就是向数据库以byte形式存入
向数据库中保存不同类型的文件,和在数据库中保存图片是一样的。就是向数据库以byte形式存入
然后就是写入数据库,代码如下:
FileInfo fi = new FileInfo( txtFileName.Text );// Replace with your file name
if ( fi.Exists
{
byte[] bData = null;
int nNewFileID = 0;
// Read file data into buffer
using ( FileStream fs = fi.OpenRead() )
{
bData = new byte[fi.Length];
int nReadLength = fs.Read( bData,0, (int)(fi.Length) );
}
// Add file info into DB
string strQuery = "INSERT INTO FileInfo "
+ " ( FileName, FullName, FileDat