问题
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