By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

passing long filenames as arguments to command line

P: n/a
I'm running a console application (ghostscript) by starting it as a process
with arguments.

The problem i'm having is that it's falling over when I pass a file
containing spaces in the filename or filepath.

Anyone know how to get around this? (i've tried putting the file in quotes,
but it doesn't seem to work e.g. -sPDFname#"filename")
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I just posted a question regarding this, albeit with an always changing
number of arguments. This is how I've been able to get all the arguments
passed correctly, when the number of arguments is always static. Just
modify the 'applaunch.StartInfo.Arguments' line to adjust the number of
arguments accordingly. Each space between arguments, or even in a
filename/path, represents an increase in arrayCount. Let me know how it
goes...
Dim applaunch As Process = New Process()
Dim arrayCount As Integer, appArgs() As String

'pull external exe path/name and args into array, then count array items
appArgs = System.Environment.GetCommandLineArgs
For arrayCount = 0 To UBound(appArgs)
Next arrayCount

applaunch.StartInfo.FileName = appArgs(1)
applaunch.StartInfo.Arguments = appArgs(2) & " " & appArgs(3) & " " &
appArgs(4)
"Colmag" <Co****@discussions.microsoft.com> wrote in message
news:49**********************************@microsof t.com...
I'm running a console application (ghostscript) by starting it as a process with arguments.

The problem i'm having is that it's falling over when I pass a file
containing spaces in the filename or filepath.

Anyone know how to get around this? (i've tried putting the file in quotes, but it doesn't seem to work e.g. -sPDFname#"filename")

Nov 21 '05 #2

P: n/a
I was adding the quotes in the wrong place. I was saying
-sPDFname#"filename" when I should have been saying "-sPDFname#filename"

"Colmag" wrote:
I'm running a console application (ghostscript) by starting it as a process
with arguments.

The problem i'm having is that it's falling over when I pass a file
containing spaces in the filename or filepath.

Anyone know how to get around this? (i've tried putting the file in quotes,
but it doesn't seem to work e.g. -sPDFname#"filename")

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.