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

时间:2019-07-19 17:50:58

标签: c# winforms

我需要在Windows Form App上存储一些视频。我可以对应用程序进行编码以从文件路径播放,但是我想知道是否有一种方法可以将视频存储在应用程序上,因为该应用程序打算被分发,并且我希望将其集成在一起。

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

在C#.net中使用Fileupload Conntrol保存视频文件该怎么办?我只提出建议。

try
        {
            UploadVideo obj = new UploadVideo();
            string filename = fuUploadVideo.FileName;
            string path = Server.MapPath("Uploads4");
            string strFinalFileName = Path.GetFileName(fuUploadVideo.FileName);
            long FileLength = fuUploadVideo.PostedFile.ContentLength;
            long uploadchunklimit;
            int SizeLimit = (int)FileLength;
            if (FileLength <= 1024)
            {
                uploadchunklimit = 1;
                SizeLimit = (int)FileLength;
            }
            else if (FileLength > 1024)
            {
                uploadchunklimit = FileLength / 1024;
                SizeLimit = 10;
            }
            else if (FileLength <= 10240 && FileLength > 1024)
            {
                uploadchunklimit = FileLength / 1024;
            }
            else
            {
                uploadchunklimit = FileLength / 1024;
            }

            long lngSize = (long)SizeLimit;
            lngSize = 1024 * 1024;
            string ext = Path.GetExtension(fuUploadVideo.PostedFile.FileName);

            fuUploadVideo.PostedFile.SaveAs(Server.MapPath("Uploads4\\" + filename));
            path = "Uploads4\\" + filename;
            SqlConnection con = new SqlConnection(str);

            cmd = new SqlCommand("Insert into electronicmedia(Video_Name,url) values(@Video,'" + path + "')", con);
            cmd.Parameters.AddWithValue("Video", TextBox2.Text);
            cmd.CommandType = CommandType.Text;
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            lblinfo.Text = " uploaded successfully ";
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }

答案 2 :(得分:0)

您可以在项目中使用 SQL Server Compact 。它将被嵌入Windows窗体应用程序中,并且您可以将文件保留在二进制列中。

还有其他可能性可以考虑:

MSDN来源:https://social.msdn.microsoft.com/Forums/en-US/0b5f6406-aef7-41a3-9560-bfe658f7d3c5/c-store-all-files-folders-in-a-windows-form?forum=winforms