M
mcolson
I am using opentextfilewriter to create a batch file and have been
getting some junk on the first line of the file (first line only). It
is not visible when viewing the file. However if I use a Hex Text
Editor, I can see a couple of garbage characters on the first line.
The computer also complains when I try and run the program, saying it
doesn't recognize I can however copy and paste the text into another
batch file and it will work perfectly. What may be causing this
garbage to be created. Here is my code.
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(strBatchFilePath,
False)
file.WriteLine("@ Echo Off")
file.WriteLine("for /f ""tokens=1-5 delims=/ "" %%d in (""%date%"") do
SET YEAR=%%g")
The garbage I'm seeing is always on the first line. If I append to an
existing file, I do not see this problem. It happens when I choose to
overwrite or create a new file.
I am using Microsoft Visual Basic Express Edition.
Here is the error I get when running the batch file.
C:\>¡É¨[©´@ Echo Off
'¡É¨[©´@' is not recognized as an internal or external command,
operable program or batch file.
If I write a blank line first I get:
C:\>¡É¨[©´
'¡É¨[©´' is not recognized as an internal or external command,
operable program or batch file.
Thanks in advance for any help.
getting some junk on the first line of the file (first line only). It
is not visible when viewing the file. However if I use a Hex Text
Editor, I can see a couple of garbage characters on the first line.
The computer also complains when I try and run the program, saying it
doesn't recognize I can however copy and paste the text into another
batch file and it will work perfectly. What may be causing this
garbage to be created. Here is my code.
Dim file As System.IO.StreamWriter
file = My.Computer.FileSystem.OpenTextFileWriter(strBatchFilePath,
False)
file.WriteLine("@ Echo Off")
file.WriteLine("for /f ""tokens=1-5 delims=/ "" %%d in (""%date%"") do
SET YEAR=%%g")
The garbage I'm seeing is always on the first line. If I append to an
existing file, I do not see this problem. It happens when I choose to
overwrite or create a new file.
I am using Microsoft Visual Basic Express Edition.
Here is the error I get when running the batch file.
C:\>¡É¨[©´@ Echo Off
'¡É¨[©´@' is not recognized as an internal or external command,
operable program or batch file.
If I write a blank line first I get:
C:\>¡É¨[©´
'¡É¨[©´' is not recognized as an internal or external command,
operable program or batch file.
Thanks in advance for any help.