如何处理打开程序的文件? [英] How to handle a file that opens the program?

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

问题描述

大家好,



我遇到了一个问题,我不知道如何解决它谷歌对此毫无用处! (顺便说一句,我使用VB.net,除此之外的任何东西都会让我感到困惑)。



所以我需要能够双击一个文件,这个文件打开程序,程序依次打开文件。



现在,文件关联和打开文件的程序是排序的,不是问题...但是我怎样才能获得用于打开程序的文件目录,毕竟它可以在任何地方!



任何输入都将被大大接受,



感谢您的时间!



i完成了该计划,但现在(在我发布给我之后)服务器然后安装,当作为默认程序运行时,它不能使用getcommandlineargs正确读取目录吗?)



再次感谢

hi all,

i have come across a problem, and i am not sure how to solve it Google is useless for this! (i use VB.net by the way and anything other than that right now will confuse me).

So i need to be able to double click on a file, this file opens the program and the program in turn opens the file.

now, the file association and the program opening a file is sorted, not an issue...but how can i get the directory of the file that is being used to open the program, after all it could be anywhere!

any input will be greatly accepted,

thanks for your time!

i finished the program but now (after I've published it to my server and then installed, when running as a default program it doesn't read the directory correctly using getcommandlineargs any more ideas?)

thanks again

推荐答案

打开程序的文件的完整路径可用作命令行上的第二个(索引1)参数:



Environment.GetCommandLineArgs [ ^ ]



所以文件的完整路径是Environment.GetCommandLineArgs()(1)



(索引0是可执行文件名/ path)。
The full path of the file that "opened" the program is available as the second (index 1) argument on the command line:

Environment.GetCommandLineArgs[^]

So the full path of the file is Environment.GetCommandLineArgs()(1)

(Index 0 is the executable name/path).


请参阅我对VB.NET与C#的评论。这是一个好消息:您可以100%准确地轻松自动地将一个翻译成另一个。有在线和离线/独立的解决方案,所以,首先,要注意开源的工具ILSpy,它可以轻松地将整个项目从C#转换为VB.NET并返回。请看我过去的答案:

代码解释,C#到VB.NET [ ^ ]。



现在,拥有所有这些,您可以轻松使用C#项目同样。首先,您可以简单地构建可用的项目,在VB.NET项目中引用程序集,并使用与VB.NET中完全相同的内容。在这种方法中,你根本看不出任何区别。你也可以翻译,你需要它才能更好地理解。



那说,不是你可以在命令行参数上使用我的工作,这非常容易使用(还有一个,更复杂,在我的文章中推荐):基于枚举的命令行实用程序 [ ^ ]。



祝你好运,

-SA
Please see my comment about VB.NET vs C#. Here is the good news: you can easily and automatically translate one into another with 100% accuracy. There are on-line and off-line/stand-along solutions, so, first of all, pay attention for the open-source stand-along tool, ILSpy, which can easily translate the whole project from C# to VB.NET and back. Please see my past answers:
Code Interpretation, C# to VB.NET[^].

Now, armed with all that, you can easily use C# projects as well. First, you can simply build available projects, references the assembly in your VB.NET project and just use in exact same was as it was in VB.NET. In this approach, you simply won't see any difference. And you also can translate, it you need it for better understanding.

That said, not you can use my work on command-line parameters, which is extremely easy to use (and one more, more complicated, is recommended in my article): Enumeration-based Command Line Utility[^].

Good luck,
—SA


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

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