如何在Windows窗体应用程序上存储视频

我需要在我的 Windows 窗体应用程序上存储一些视频。我可以对应用程序进行编码以从文件路径播放,但我想知道是否有一种方法可以将视频存储在应用程序上,因为该应用程序旨在传播,并且我希望将整个内容集成起来。



红糖糍粑
浏览 147回答 3
3回答

拉风的咖菲猫

也许您可以将视频文件添加为嵌入式资源?在项目的资源选项卡中,您应该能够选择和更改资源及其设置。

尚方宝剑之说

您可以在项目中使用SQL Server Compact 。它将嵌入到您的 Windows 窗体应用程序中,您可以将文件保存在二进制列中。还可以考虑其他可能性:将视频保存在程序子文件夹中的常规文件夹中(或用户文件夹中)您可以使用嵌入式资源(如前面的答案中提到的)使用Windows 支持的复合文件。

杨魅力

在 C#.net 中使用 Fileupload Control 保存视频文件怎么样?我只给出建议。try&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; UploadVideo obj = new UploadVideo();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string filename = fuUploadVideo.FileName;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string path = Server.MapPath("Uploads4");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string strFinalFileName = Path.GetFileName(fuUploadVideo.FileName);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; long FileLength = fuUploadVideo.PostedFile.ContentLength;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; long uploadchunklimit;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int SizeLimit = (int)FileLength;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (FileLength <= 1024)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uploadchunklimit = 1;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SizeLimit = (int)FileLength;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (FileLength > 1024)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uploadchunklimit = FileLength / 1024;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SizeLimit = 10;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if (FileLength <= 10240 && FileLength > 1024)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uploadchunklimit = FileLength / 1024;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uploadchunklimit = FileLength / 1024;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; long lngSize = (long)SizeLimit;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lngSize = 1024 * 1024;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; string ext = Path.GetExtension(fuUploadVideo.PostedFile.FileName);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fuUploadVideo.PostedFile.SaveAs(Server.MapPath("Uploads4\\" + filename));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path = "Uploads4\\" + filename;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SqlConnection con = new SqlConnection(str);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd = new SqlCommand("Insert into electronicmedia(Video_Name,url) values(@Video,'" + path + "')", con);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd.Parameters.AddWithValue("Video", TextBox2.Text);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd.CommandType = CommandType.Text;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; con.Open();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd.ExecuteNonQuery();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; con.Close();&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lblinfo.Text = " uploaded successfully ";&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; catch (Exception ex)&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Response.Write(ex.ToString());&nbsp; &nbsp; &nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP