2

So, basically, without having any Visual Studio experience, I wanted to improve my animation workflow. So, I wanted to use stuff found in http://www.aseprite.org/cli/ to do that.

So, I made a little program to get all .ase files in a folder and make a text file containing the lines needed for the batch file to convert the said .ase files to either .gif or png files. I'm stupid, so I manually convert the text file to a .bat file.

But the .txt files generated from the program do not work when converted to .bat, but if I copy the lines to another .txt file I create in windows, and convert it to .bat, it works.

So the question is - do I corrupt the .txt file in Visual Studio or something? If there's a problem with the code, I'll share it, but I'm reluctant, cause I don't want to have a formatting mistake nightmare.

Oh, and yeah, I know this isn't a smart way to go about.

EDIT: Ah, right, the error of the batch file, which, by the way, flashed by extremely quickly and closes the command line prompt: '--batch' is not recognized as an internal or external command, operable program or batch file.

The code in .bat is like:

@set ASEPRITE="C:\Program Files\Aseprite\aseprite.exe"
%ASEPRITE% --batch animation.ase --scale 2 --save-as animation-x2.gif
%ASEPRITE% --batch animation.ase --scale 4 --save-as animation-x4.gif

And basically in VB I create the txt file and text like this:

' Dim fs As FileStream = File.Create(Label1.Text + "\Text.txt")
    fs.Close()

    For Each foundFile As String In My.Computer.FileSystem.GetFiles(Label1.Text)

        Dim check As String = System.IO.Path.GetExtension(foundFile)

        If check = ".ase" Then
            ListBox1.Items.Add(Dir(foundFile))
            str = Dir(foundFile)
            str = str.Replace(".ase", fType)
            My.Computer.FileSystem.WriteAllText(Label1.Text + "\Text.txt",
                                                "%ASEPRITE% --batch " + Dir(foundFile) + " --scale " + fSize + " --save-as " + str + vbCrLf,
                                                True)
        End If
    Next

'

lagxbag
  • 71
  • 6

1 Answers1

3

You can try to write the file with a specific encoding:

File.WriteAllText(path, text, Encoding.UTF8) ' or UTF or ASCII

It could also be that the UTF8 encoder uses a Byte Order Mark which can't be read:

File.WriteAllText(path, text, new UTF8Encoding(false))

The other thing to look for is end of line characters. Is it \r\n or just \n?

You can use a file comparer to check the difference between the files, and it should become clear what the difference is.

codekaizen
  • 26,990
  • 7
  • 84
  • 140