winform 上传文件至数据库

KevinHu_CS KevinHu_CS 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
string strDocExt;
//string strDocType;
int intDocLen;
string filePath = "";

FileStream objStream;
if (fileName == "")
{
MessageBox.Show("要上传的文件不允许为空!", "系统提示");
}
else
{
filePath = fileName;
strDocExt = filePath.Substring(filePath.LastIndexOf(".") + 1);
string filen = filePath.Substring(filePath.LastIndexOf("\\") + 1);
objStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
if(objStream.CanRead)
{
intDocLen = Convert.ToInt32(objStream.Length);
byte[] Docbuffer = new byte[intDocLen];
objStream.Read(Docbuffer, 0, intDocLen);

InsertFile(filen,Docbuffer, strDocExt, extendedName);
}
}


这是我写的上传文件到数据库。
不知道那写的有问题
下载下来的数据为System.Byte[]
不知道为什么byte[]里面没有字节数
...全文
评论 12
收藏 已收藏
分享
返回顶部
KevinHu_CS
C# 111,129 成员 642,539 内容