简体   繁体   中英

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. 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. 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. Here's the MSDN page on that.

You can specify which program you want to start with whetever arguments you need, like in this example.

Edit: Added another example. Thanks @DJBurb

Process.Start(@"c:\\abc.mov");

This code should open the .mov file with the default movie player associated with the .mov extension.

我相信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);
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM