[英]Open video file in C#
I am new to C# and this might sound stupid, I did some research and I think I am confused. 我是C#的新手,这听起来可能很愚蠢,我做了一些研究,但我觉得很困惑。 I want my c# program to open a video file (c:\\abc.mov), I have set the .mov files to open automatically with quick time player and I want the program to open the file with quick time player just like double clicking on that file.
我希望我的c#程序打开一个视频文件(c:\\ abc.mov),我已将.mov文件设置为使用快速播放器自动打开,并且我希望该程序使用快速播放器打开文件,就像双击一样在那个文件上。 When I use this code it does not do anything!
当我使用此代码时,它什么也不做!
File.Open(@"c:\abc.mov", FileMode.Open);
Please help me? 请帮我?
You should use Process.Start
instead. 您应该改用
Process.Start
。 Here's the MSDN page on that. 这是关于此的MSDN页面 。
You can specify which program you want to start with whetever arguments you need, like in this example. 您可以使用所需的任意参数指定要启动的程序, 如本例所示。
Edit: Added another example. 编辑:添加了另一个示例。 Thanks @DJBurb
谢谢@DJBurb
Process.Start(@"c:\\abc.mov");
This code should open the .mov
file with the default movie player associated with the .mov
extension. 此代码应使用与
.mov
扩展名关联的默认电影播放器打开.mov
文件。
我相信open()将打开您的文件以供当前程序编辑,而不是使用系统的默认播放器实际打开文件
File.Open
返回FileStream
因此您可以读取该文件,相反,您绝对想使用Process.Start(@"c:\\abc.mov");
这将使用dafault视频播放器打开您的视频文件
System.Diagnostics.Process.Start(filepath);
private void buttonOpen_Click(object sender, EventArgs e)
{
if (ofd.ShowDialog()==DialogResult.OK)
{
Process.Start(ofd.FileName);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.