在 VB 中创建的 .txt 文件与我随机创建的文件不同吗?

Is a .txt file created in VB different than one I'd randomly create?

所以,基本上,在没有任何 Visual Studio 经验的情况下,我想改进我的动画工作流程。所以,我想使用在 http://www.aseprite.org/cli/ 中找到的东西来做到这一点。

因此,我制作了一个小程序来获取文件夹中的所有 .ase 文件,并制作一个文本文件,其中包含批处理文件将所述 .ase 文件转换为 .gif 或 png 文件所需的行。我很笨,所以我手动将文本文件转换为.bat文件。

但是从程序生成的 .txt 文件在转换为 .bat 时不起作用,但是如果我将这些行复制到我在 windows 中创建的另一个 .txt 文件并将其转换为 .bat,它有效。

所以问题是 - 我是否损坏了 Visual Studio 中的 .txt 文件? 如果代码有问题,我会分享,但我不愿意,因为我不想有格式错误的噩梦。

哦,是的,我知道这不是一个明智的做法。

编辑:啊,对了,批处理文件的错误,顺便说一下,它一闪而过并关闭了命令行提示:“--​​batch”不被识别为内部或外部命令,可运行的程序或批处理文件。

.bat 中的代码如下:

@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

基本上在 VB 中,我创建了这样的 txt 文件和文本:

' 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

'

您可以尝试使用特定编码写入文件:

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

也可能是UTF8编码器使用了无法读取的字节顺序标记:

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

要查找的另一件事是行尾字符。是 \r\n 还是只是 \n

您可以使用文件比较器来检查文件之间的差异,应该清楚差异是什么。