Roku: Reading a text file present in server

2019-07-16 15:36发布

I want to read a text file present in a server from my Roku program. I reffered the following question. Read and write from temp file in Roku

The above link has solution to read file from tmp/. So, I tried something like this:

text=ReadAsciiFile("<server_file_path>/file.txt")

But it is not able to open the file. Is there any other way to read a text file present in server?

2条回答
倾城 Initia
2楼-- · 2019-07-16 16:22

The code given in SDK document is too complicated for just to read a text file from server.

The following code worked from me.

Sub readTextFromServer(serverURL as String) as String
        readInternet = createObject("roUrlTransfer")
        print "Getting URL from: ";serverURL
        readInternet.setUrl(serverURL)
        myText= readInternet.GetToString()
        print "Text from server: ";myText

        return myText
End Sub
查看更多
Luminary・发光体
3楼-- · 2019-07-16 16:40

ReadAsciiFile() is only used to read files from pkg:/ and tmp:/ directories. You should use rourltransfer for this.

查看更多
登录 后发表回答