Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I have a console application which is going to run on a server that searches a directory for any post-script files and converts them to .pdf files. Currently the directory it searches is 'hard-coded' in the app.config file, but when I deploy this I want the client to be able to 'pass' a directory name for it to search in. Is there any way to do this with a console application? Thanks in advance for any help!
Posted
Of course there is; you can pass the path as a parameter when you start the app.

 

Right, so say I do something like:

 

"Ps2PdfConversionTool.exe" \\sourceDirectory\

 

What do I use to access the directory name? args(0)? Thanks.

Posted
Public Sub Main(ByVal Args() As String)
 If Args.Length > 0 Then
   'validate argument and if correct start the task - Args(0) contains the path
 Else
   Console.WriteLine("Arguments missing")
 End If
End Sub

Posted
Public Sub Main(ByVal Args() As String)
 If Args.Length > 0 Then
   'validate argument and if correct start the task - Args(0) contains the path
 Else
   Console.WriteLine("Arguments missing")
 End If
End Sub

 

Yeah just tried it and it works. Thanks for your help :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...