Lua中将文本文件中的备忘录行追加

我使用cmd命令使用lua脚本获取我的RAM信息:

cmd = 'wmic MEMORYCHIP get BankLabel, Capacity, DeviceLocator,  MemoryType, TypeDetail, Speed,Tag >'..path..'MyRAMDetail.txt'
os.execute(cmd)

该代码将在我的本地磁盘上生成一个文件:MyRamDetail.txt。当通过记事本打开时,它包含类似于以下内容的文本:

BankLabel  Capacity    DeviceLocator   MemoryType  Speed  Tag                TypeDetail
BANK 0     8589934592  ChannelA-DIMM0  0           1333   Physical Memory 0  128

但是,当我使用Lua脚本将所有文本追加到备忘录中或将其打印时,它显示为:

??B

我正在使用此Lua脚本向备忘录添加行:

local open = io.open

function read_file(fpath)
  local file = open(fpath, "rb")
  if not file then return nil end
  local content = file:read "*a"
  file:close()
  return content
end

local path = 'C:\\'
local fileContent = read_file(path..'MyRAMDetail.txt')
-- print (fileContent) check it
memo1.Lines.Text = fileContent

如何正确打印文件内容或将所有文本追加到备忘录中?

敬礼

点赞