[英]How to store a video file in exe file in c# and play it
我在 c# 中使用 winForms。 我想在不使用任何对话框加载或选择的情况下从资源访问视频文件。 这意味着我想直接将视频文件存储在 EXE 文件中。
private void startBtn_Click(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL=(videoForms.Properties.Resources.Airtel.wmv).ToString();
axWindowsMediaPlayer1.Ctlcontrols.play();
}
我在执行此代码时收到警告。 警告是“与文件格式不匹配的字节[]”请帮我运行这段代码。
谢谢你。
脚步:
代码:
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();
}
截屏:
更多信息:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.