如何用我的程序打开我的文件? [英] How to open my file with my program?

查看:85
本文介绍了如何用我的程序打开我的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨亲爱的

我用c#编写了一个视频播放器。

这个程序试图读取* .KMPC文件。

在我的程序中,我应该定义文件路径和文件名。例如@c:/MyVideoFile.kmpc

现在我必须将我的所有文件重命名为驱动器C,然后运行程序。

我想克服这个问题并修改我的程序。我希望如果我双击任何驱动器中的任何名称,我可以识别文件路径和文件名。

请帮助我

Hi dears
I programmed a video player in c#.
this program is trying to read "*.KMPC" files.
in my program I should define the file path and the file name. For example @"c:/MyVideoFile.kmpc"
Now I have to rename all my files in copy that file into Drive "C" and after that Run the program.
I want to overcome this issue and modify my program. I want if I double-click in my fine with any name in any Drive My program will enable to recognize the file path and file name.
Please help me

推荐答案

这是一个两步完成的过程。

1)告诉你的操作系统将文件传递给你的程序

2)让你的能够处理操作系统调用的程序



1)右键单击其中一个视频文件,

选择打开方式>和

选择标准应用程序

搜索程序的文件系统



2)操作系统调用你的将该文件作为命令行参数编程。

您可以通过 GetCommandLineArgs方法

在你的软件中,检查该参数列表中是否有有效的文件名,如果有,请播放文件而不是硬编码文件。



对于更复杂的命令行解析器,请查看 C#/ .NET命令行参数解析器重装上阵
It's a 2-step process to get that done.
1) tell your OS to pass the file to your program
2) make your program capable of handling the OS call

1) Right-click on one of the video files,
choose "Open with >" and
"Choose standard application"
Search the file system for your program

2) OS calls your program with the file as a command-line parameter.
You can access that parameter via the GetCommandLineArgs method.
In your software, check if there is a valid filename in that argument list and if there is, play that file instead of the hard-coded one.

For a more sophisticated command line parser, have a look at C#/.NET Command Line Argument Parser Reloaded


使用 OpenFileDialog类 [ ^ ]。


这篇关于如何用我的程序打开我的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆