通过命令行参数传递路径 [英] passing a path via commandline argument

查看:204
本文介绍了通过命令行参数传递路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我正在尝试通过命令行参数将文件夹路径传递给应用程序.

I'm trying to pass a folder path via commandline argument to an application.

问题:我的文件夹路径的字符串中包含空格" ".当我在应用程序中读取命令行参数时,我的路径在空间中被切成碎片 " "

Problem: my folder path contains space " " in it's string. When I read the commandline arguments in the application I get my path chopped into pieces on the space " "

Sub Main()

    Dim arguments As String() = System.Environment.GetCommandLineArgs()
    For Each Arg As String In arguments
        Console.WriteLine("Argument : " & Arg)
    Next

    Console.ReadLine()

End Sub

如何在没有将其转换为多个参数的情况下传递路径?

How can I pass a path without it beeing converted in multiple arguments?

推荐答案

 作为参数传递的路径必须如果其中有空格,请用引号引起来.

 A path passed as an argument must be enclosed in quotes if it has any spaces in it.

"C:\ My Folder \ Some File.txt"


这篇关于通过命令行参数传递路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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