获取原始(未分割)命令行中的.NET [英] Getting raw (unsplit) command line in .NET

查看:148
本文介绍了获取原始(未分割)命令行中的.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET中,我们可以很容易地从主(字符串[])环境参数访问分割命令行参数的字符串数组.GetCommandLineArgs()。但是,有没有办法让非解析命令行作为一个字符串?

In .NET, we can easily access split command line arguments in a string array from the argument of Main(string[]) or Environment.GetCommandLineArgs(). However, is there a way to get the unparsed command line as one string?

背景:我的应用程序添加自己FileExplorer上下文菜单(如记事本++一样)。时,它的发射这种方式,文件名被传递,而不引用,这意味着如果有在路径中的空间,它的细分。我知道我可以拥抱%1 用引号引起来解决此问题在注册表中如 MyApp.exe将%1 ,但是当我检查其他应用程序的注册表中,他们并没有这样做。他们是普通的像 NOTEPAD.EXE%1 - 他们得到了完整的命令行。我想知道是否有可能在.NET和如何。

Background: my app is adding itself to FileExplorer context menu (like Notepad++ does). When it's launched this way, the filename is passed in without quoting, which means if there are spaces in the path, it's broken down. I know I can fix this by embrace %1 in quotation marks in the registry like myapp.exe "%1", but when I check other application's registry they didn't do so. They are plain like notepad.exe %1 - they got the complete command line. I want to know if it is possible in .NET and how.

推荐答案

尝试使用Environment.CommandLine

Try using Environment.CommandLine

这篇关于获取原始(未分割)命令行中的.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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