read lines from textfile and treat them as Main(args)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken Snyder

    read lines from textfile and treat them as Main(args)

    hi ng,

    reading a file line by line is no big match, but
    i would like to read them and convert them to
    string[] as if they where given like command
    line args so that i can preprocess them and hand
    them over to my real main. how can i do that?
    I will write the command line args into a file and
    read them from there as if they were given from
    the command line. can you give me a short example
    please?

    thanks in advance

    cheers
    ken


  • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

    #2
    Re: read lines from textfile and treat them as Main(args)

    Ken Snyder wrote:
    reading a file line by line is no big match, but
    i would like to read them and convert them to
    string[] as if they where given like command
    line args so that i can preprocess them and hand
    them over to my real main. how can i do that?
    I will write the command line args into a file and
    read them from there as if they were given from
    the command line. can you give me a short example
    please?
    Use File.ReadAllLin es !

    Arne

    Comment

    • Ken Snyder

      #3
      Re: read lines from textfile and treat them as Main(args)

      hi arne,

      what i meant was somthing like this:

      file lines:

      -p 123 -k 45 -h78
      -k 54 -p 123 -a 45

      the read each line with streamreader.re adline
      and then convert the read line string into string[]
      like the applications args. i would like to pass the
      read line to the app main args.


      cheers
      ken




      Comment

      • =?ISO-8859-1?Q?Arne_Vajh=F8j?=

        #4
        Re: read lines from textfile and treat them as Main(args)

        Ken Snyder wrote:
        what i meant was somthing like this:
        >
        file lines:
        >
        -p 123 -k 45 -h78
        -k 54 -p 123 -a 45
        >
        the read each line with streamreader.re adline
        and then convert the read line string into string[]
        like the applications args. i would like to pass the
        read line to the app main args.
        File.ReadAllLin es(fnm) will return:
        { "-p 123 -k 45 -h78", "-k 54 -p 123 -a 45" }

        File.ReadAllTex t(fnm).Split(" \r\n".ToCharArr ay(),
        StringSplitOpti ons.RemoveEmpty Entries)
        will return:
        { "-p", "123", "-k", "45", "-h78", "-k", "54", "-p", "123", "-a", "45" }

        You pick what you want.

        Arne

        Comment

        • Ken Snyder

          #5
          Re: read lines from textfile and treat them as Main(args)

          hey, thats cool! thanks

          cheers
          ken


          "Arne Vajhøj" <arne@vajhoej.d kschrieb im Newsbeitrag
          news:485f140e$0 $90268$14726298 @news.sunsite.d k...
          Ken Snyder wrote:
          what i meant was somthing like this:

          file lines:

          -p 123 -k 45 -h78
          -k 54 -p 123 -a 45

          the read each line with streamreader.re adline
          and then convert the read line string into string[]
          like the applications args. i would like to pass the
          read line to the app main args.
          >
          File.ReadAllLin es(fnm) will return:
          { "-p 123 -k 45 -h78", "-k 54 -p 123 -a 45" }
          >
          File.ReadAllTex t(fnm).Split(" \r\n".ToCharArr ay(),
          StringSplitOpti ons.RemoveEmpty Entries)
          will return:
          { "-p", "123", "-k", "45", "-h78", "-k", "54", "-p", "123", "-a",
          "45" }
          >
          You pick what you want.
          >
          Arne

          Comment

          Working...