Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
liran
Visitor

Write to USB file

(I Saw this thread:
viewtopic.php?p=197784 )

I need to write a file on my app that will remain there on the next app runs.
From my understanding, I can write to 'tmp', but it will be deleted on the next run.
So my next, less wanted option is to write to a USB drive.
I put a USB, with FAT32, and with FAT format.
However, it failed to write to it. This is my code:

usbfile = "ext1:/usb.txt"
tempfile = "tmp:/temp4.txt"
success = WriteAsciiFile(tempfile,"writeusb2")
print success ' this is true
'copy from local to USB drive.
filesystem = CreateObject("roFileSystem")
success = filesystem.CopyFile(tempfile,usbfile) ' this is false !!!
print success

Why is the last 'success' value false ?

Thanks
0 Kudos
5 REPLIES 5
RokuMarkn
Visitor

Re: Write to USB file

Using the USB for this purpose is not a very good solution. First, not all Roku devices have a USB port. Second, the user could remove the USB drive that you wrote to, or modify the file that you wrote. The Registry is a much better solution. It is designed to hold persistent application data. See roRegistry in the Component Reference.

--Mark
0 Kudos
liran
Visitor

Re: Write to USB file

Thanks, I'll try it.
0 Kudos
EnTerr
Roku Guru

Re: Write to USB file

So umm, why does filesystem.CopyFile(tempfile,usbfile) fail?

Is the file system mounted read-only or what?! Does it matter if it's FAT, NTFS or?
You may assume i have legitimate use for read-write mount.
0 Kudos
renojim
Community Streaming Expert

Re: Write to USB file

From the documentation: "The USB filesystems are currently mounted read only."

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
EnTerr
Roku Guru

Re: Write to USB file

"renojim" wrote:
From the documentation: "The USB filesystems are currently mounted read only."
-JT
Thanks, could have read that myself huh.
Why are they still read-only if mounting was added in 2.6? I am guessing nobody wants to deal with flushing needed when dismounting (and esp the UI aspects of that)... crud.
0 Kudos