新手请教,用c#如何读取别人机子上的视频文件并保存

yangmeihua 2007-04-18 01:01:10
用c#如何读取别人机子上的视频文件并保存?
...全文
234 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
yangmeihua 2007-04-18
  • 打赏
  • 举报
回复
谢谢了,我要把他做成一个cs架构的程序
miaohuayinggxlx 2007-04-18
  • 打赏
  • 举报
回复
我现在也正在做一个同学录.要考虑歌曲的上传和播放.主要采取二进制的办法.
HttpPostedFile UpFile =this.File1.PostedFile; //HttpPostedFile对象,用于读取图象文件属性
FileLength = UpFile.ContentLength; //记录文件长度
try
{
if (FileLength == 0)
{ //文件长度为零时
this.lblInfo.Text = "<b>请你选择你要上传的文件</b>";
}
else
{

Byte[] FileByteArray = new Byte[FileLength]; //图象文件临时储存Byte数组
Stream StreamObject = UpFile.InputStream; //建立数据流对像
//读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
StreamObject.Read(FileByteArray,0,FileLength);
//建立SQL Server链接
SqlConnection Con = new SqlConnection("uid=sa;pwd=19830517;initial catalog=SWFCXYL;data source=.");
//String SqlCmd = "INSERT INTO ImageStore (ImageData, ImageContentType, ImageDescription, ImageSize) VALUES (@Image, @ContentType, @ImageDescription, @ImageSize)";
string SqlCmd="insert into song (username,accept,songname,songaddr,Content,songtype,songsize) values(@username,@accept,@songname,@songaddr,@Content,@songtype,@songsize)";

SqlCommand CmdObj = new SqlCommand(SqlCmd, Con);
CmdObj.Parameters .Add ("@username",SqlDbType.VarChar ,20).Value=this.lblUserName.Text ;
CmdObj.Parameters .Add ("@accept",SqlDbType.VarChar ,20).Value=this.txtAcceptName.Text ;
CmdObj.Parameters .Add ("@songname",SqlDbType.VarChar ,50).Value=this.txtSongName.Text ;
CmdObj.Parameters.Add("@songaddr",SqlDbType.Binary, FileLength).Value = FileByteArray;
CmdObj.Parameters .Add ("@Content",SqlDbType.VarChar ,255).Value=this.txtRemark.Text ;

CmdObj.Parameters.Add("@songtype", SqlDbType.VarChar,50).Value = UpFile.ContentType; //记录文件类型
//把其它单表数据记录上传

//记录文件长度,读取时使用
CmdObj.Parameters.Add("@songsize", SqlDbType.Int).Value = UpFile.ContentLength;
Con.Open ();
CmdObj.ExecuteNonQuery();
Con.Close();
this.lblInfo.Text = "<p><b>OK!你已经成功上传你的图像文件</b>";//提示上传成功



}
}
catch (Exception ex)
{
this.lblInfo.Text = ex.Message.ToString();
}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧