locked
Console application RRS feed

  • Question

  • I am trying to create a console application that does the following:
    1) read a text file
    2) Save the content over to a SQL Server database
    3) Use command line arguments to allow user to specify any delimited file
    Thanks for looking!
    Wednesday, August 10, 2011 5:15 PM

Answers

  • You can get command line arguments directly from the main method, just declare your main like:

    Sub Main (ByVal args() As String)
      ' Args will be an array of command line arguments
    End Sub

    You can also use the System.Environment.GetCommandLineArgs method.


    Tom Shelton
    • Proposed as answer by Mike Feng Friday, August 12, 2011 7:40 AM
    • Marked as answer by Mike Feng Tuesday, August 23, 2011 3:08 PM
    Thursday, August 11, 2011 1:26 AM
  • Hi Mike Ham11,

    Welcome to the MSDN Forum.

    In Tom's suggestion, you should add the parameter behind of the EXE file, for example:

    1. make a shortcut of your exe file

    2. go to the shortcut tab of the property of the shortcut file

    3. add the file name at the end of the file name string in the target textbox

    when you debug your program, you can add the file name in the Command line arguments of the debug tab in the project property page.

    And here is another way to achieve this :

    Dim fileName As String = Console.ReadLine()

    You can use this line code to let the user input the filename during the application runs.

    I hope this will be helpful.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Mike Feng Tuesday, August 23, 2011 3:08 PM
    Friday, August 12, 2011 7:53 AM

All replies

  • So...  Did you have a specific question regarding this task, or are you just looking for someone to write it for you?
    Tom Shelton
    Wednesday, August 10, 2011 5:33 PM
  • I am having trouble with the command line arguments. Any help would greatly be appreciated!
    Wednesday, August 10, 2011 5:44 PM
  • What parameters you want to pass to the application?
    Ali Hamdar (alihamdar.com - www.ids.com.lb)
    Wednesday, August 10, 2011 10:18 PM
  • Sub Main()
        Dim strStartupArguments() As String = System.Environment.GetCommandLineArgs

    strStartupArguments(0) will be the name of the actual program - after that the array will contain all parameters passed

    Thursday, August 11, 2011 12:08 AM
  • You can get command line arguments directly from the main method, just declare your main like:

    Sub Main (ByVal args() As String)
      ' Args will be an array of command line arguments
    End Sub

    You can also use the System.Environment.GetCommandLineArgs method.


    Tom Shelton
    • Proposed as answer by Mike Feng Friday, August 12, 2011 7:40 AM
    • Marked as answer by Mike Feng Tuesday, August 23, 2011 3:08 PM
    Thursday, August 11, 2011 1:26 AM
  • Hi Mike Ham11,

    Welcome to the MSDN Forum.

    In Tom's suggestion, you should add the parameter behind of the EXE file, for example:

    1. make a shortcut of your exe file

    2. go to the shortcut tab of the property of the shortcut file

    3. add the file name at the end of the file name string in the target textbox

    when you debug your program, you can add the file name in the Command line arguments of the debug tab in the project property page.

    And here is another way to achieve this :

    Dim fileName As String = Console.ReadLine()

    You can use this line code to let the user input the filename during the application runs.

    I hope this will be helpful.

    Best regards,


    Mike Feng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Mike Feng Tuesday, August 23, 2011 3:08 PM
    Friday, August 12, 2011 7:53 AM