[英]How to store a video file in exe file in c# and play it
I am working with winForms in c#.我在 c# 中使用 winForms。 I want to access video file from resources without using any dialog box for load or select.我想在不使用任何对话框加载或选择的情况下从资源访问视频文件。 That means I want directly store video file in EXE file.这意味着我想直接将视频文件存储在 EXE 文件中。
private void startBtn_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL=(videoForms.Properties.Resources.Airtel.wmv).ToString();
axWindowsMediaPlayer1.Ctlcontrols.play();
}
I get warning while I execute this code.我在执行此代码时收到警告。 the warning is " byte[] that does not matches the file format" please help me to run this code.警告是“与文件格式不匹配的字节[]”请帮我运行这段代码。
Thank you.谢谢你。
Steps:脚步:
Code:代码:
private void Form_Load(object sender, EventArgs e)
{
var file=System.IO.Path.Combine(Application.StartupPath, "YourFileName.wmv");
if (!System.IO.File.Exists(file))
System.IO.File.WriteAllBytes(file, Properties.Resources.YourFileName);
this.axWindowsMediaPlayer1.URL = file;
this.axWindowsMediaPlayer1.Ctlcontrols.play();
}
Screenshot:截屏:
More information:更多信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.