【发布时间】:2015-05-03 23:56:12
【问题描述】:
我尝试在 VBScript 中为 PowerAMC 制作脚本。 我有一个错误。
我检查了所有元素以制作包含内容的文件(XSD 文件):
private Sub writeInFile(pathFolder, pathFile, val)
Output "WriteInFile["&pathFolder&pathFile&"]"
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(pathFolder&pathFile, true)
If (fso.FileExists(pathFolder&pathFile)) Then
MyFile.WriteLine(val)
Else
ouput "File can't be create"
End If
MyFile.Close
end Sub
并且该文件存在的内容很好,但如果我尝试阅读它:
public Function readFile(path)
'Declare variables
Dim objFSO, objReadFile, contents
'Set Objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile(path, 1, false)
'Read file contents
contents = objReadFile.ReadAll
'Close file
objReadFile.close
'Cleanup objects
Set objFSO = Nothing
Set objReadFile = Nothing
readFile = contents
End Function
我明白了:“ÿþ
【问题讨论】:
-
您可能正在尝试读取 UTF-8 编码文件。看看stackoverflow.com/a/13855268/4584335
标签: vbscript