Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
160 views
in Technique[技术] by (71.8m points)

c# - Getting raw (unsplit) command line in .NET

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?

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try using: Environment.CommandLine


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...