将带有空格的参数传递给批处理文件 [英] Pass Paramter with Spaces to Batch File
问题描述
我需要将文件路径作为c#.net中的参数传递给批处理文件。该路径具有空格,这将导致路径的第一部分被替换为第一个参数。我想将整个路径作为第一个参数传递给批处理文件,用
包围单引号。我试图用单引号包围路径,但不会发生变量替换。我希望变量替换首先发生,然后应用单引号。
I need to pass a file path to a batch file as a paramter in c#.net. The path has spaces which would cause the first part of the path to be substituted as the first parameter. I would like to pass the whole path as the first parameter to the batch file by surrounding with single quotes. I tried to surround the path with single quotes however variable substitution does not take place. I would like variable substitution to take place first and then have the single quotes applied.
想要在变量替换后传递以下作为参数,然后应用单引号。我得到的是字符串在替换之前作为文字传递给批处理文件像这样:
Would like to pass the following as a paramter after varaible substitution and then have the single quotes applied. What I am getting is the string is passed to the batch file as a literal before substitution Like this:
" \" MonarchModelLoc + row [" SARSFileName" ;]。ToString()。修剪()\"",
"\"MonarchModelLoc + row["SARSFileName"].ToString().Trim()\"",
我怎样才能首先进行变量替换,以便得到如下字符串:'E :\Enrollment \ Medicare Shared Services \ Erisco Reports\EPE1223 \'
How can I get variable substitution to take place first so that I get a string like: 'E:\Enrollment\Medicare Shared Services\Erisco Reports\EPE1223\'
推荐答案
" \"" + MonarchModelLoc + row [" SARSFileName"]。ToString()。Trim()+" \""
"\"" + MonarchModelLoc + row["SARSFileName"].ToString().Trim() + "\""
这篇关于将带有空格的参数传递给批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!