locked
reading a text file in post build event RRS feed

  • Question

  • I'm trying to read the contents of a text file during a post build event to use as a variable. The below code works but there is always an extra non-standard character(s) that are added to the beginning of the text when executed. How do I read the contents of the file without it including this garbage character?

    SET /a counter=0
    for /f "delims=" %%a in ('type IDDEnvironmentBreadCrumb.txt 2^>nul') do (
      if %counter% GTR 1 goto continue
      set Environment=%%a
      set /a counter+=1
     )

    :continue
    echo Environment is: %Environment%

     

    Monday, May 24, 2010 7:52 PM

Answers

  • Hi Joey,

    What's the encoding of the text file? Can you change it to ANSI for a test?

    Thanks.


    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    See what's happening in MSDN forum? Follow us at Twitter.
    Tuesday, May 25, 2010 7:21 AM

All replies

  • Hi Joey,

    What's the encoding of the text file? Can you change it to ANSI for a test?

    Thanks.


    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    See what's happening in MSDN forum? Follow us at Twitter.
    Tuesday, May 25, 2010 7:21 AM
  • Hi Joey,

    I am marking answer because I believe changing to ANSI encoding can solve the issue. Please let me know if it doesn't. Thanks.


    Hongye Sun [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    See what's happening in MSDN forum? Follow us at Twitter.
    Monday, June 28, 2010 4:56 AM