Roku: Reading a text file present in server

人走茶凉 提交于 2019-12-10 23:09:02

问题


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?


回答1:


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




回答2:


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


来源:https://stackoverflow.com/questions/38300097/roku-reading-a-text-file-present-in-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!