因此,我在网上找到了这段代码(通常是C#,但我试图向我的一个朋友传授smallbasic ),它基本上可以读取一个文件:
TextWindow.Write("Enter the name of the new directory: ")
DirectoryName = TextWindow.Read()
files = File.GetFiles(DirectoryName)
TextWindow.WriteLine("This is the content in the file: ")
TextWindow.WriteLine(File.ReadContents(files[1])) 我明白这一切的作用,但是为什么它需要是files[1]而不是files?
删除索引[1]只会使行不能工作,程序仍然会编译等等。
SB没有调试器,在线资源也不是很好。
发布于 2013-09-22 17:57:57
根据API文档,File.GetFiles返回一个数组:
如果操作成功,这将使将文件作为数组返回。否则,它将返回“失败”。
指定索引是因为它返回一个数组,File.ReadContents需要一个实例。
在这里查看API:http://smallbasic.com/doc/?id=6
https://stackoverflow.com/questions/18946937
复制相似问题