# Read and Write to file, from Widget?



## allegutta (May 4, 2010)

Hi,

Is there a way I can make a widget read and write to file(on my local computer)?

Best,
allegutta


----------



## Giaguara (May 5, 2010)

Yes.
Any widget that contains or stores data locally, does it on your hard drive. So for instance  the data written in stickies widget will be read and written on your local hard drive.
But you probably had something a bit more specific in your mind if I'm not mistaken?


----------



## ElDiabloConCaca (May 5, 2010)

If you're talking about Dashboard widgets, then I'm not sure if they can or can't, but I would suspect that they cannot.

Dashboard widgets are typically written in Javascript, or a combination of Javascript and other typically web-based technologies.  Javascript does not have access to the filesystem as another more low-level programming language might.


----------



## allegutta (May 5, 2010)

Hi!

I want to make a widget where I type in my name and it store that name in a text file. And I want the widget to read from another text file. 

I have googeled around and I know it can be a little hard to make javascript do this, but since this is a local dashboard widget - I hoped there would be a solution for this?

Best,
Sigurd


----------



## Giaguara (May 6, 2010)

What other applications do you need to use the content of those text files?

If it's only a few files you need to get read/written all the time, then the Stickies widget may be enough for you. Everything it stores is locally.

If it's something more complicated, the widget developer reference isn't a bad place to start (for even writing your own). The links are for 10.4 but they are essentially the same for 10.6.

http://developer.apple.com/mac/libr...//apple_ref/doc/uid/TP40001339-CH205-BAJCBIDE



> Info.plist option
> AllowFileAccessOutsideOfWidget
> Optional; specify if your widget requires access to the file system outside of your widget. Access is limited by the user&#8217;s permissions



According to that one option alone, you could specify your widget to access a file outside it (as long as the user can access it).

http://developer.apple.com/macosx/dashboard.html
http://developer.apple.com/mac/library/navigation/index.html#topic=Guides&section=Resource+Types
http://developer.apple.com/mac/libr.../Dashboard_Ref/DashboardRef/DashboardRef.html

If there are only a few files that you want to use with Dashboard all the time, copy each to a separate sticky. 
Those files can contain quite a bit of text, and you can have dozens of them, and minimize when not in use. 
That way you don't have to worry about the files separately, just create stickies for whatever you need (e.g. I used about 20 different ones for frequently copy pasted material at work this way)


----------



## alexdung (May 10, 2010)

Dashboard widgets are typically written in Javascript, or a combination of Javascript and other typically web-based technologies. Javascript does not have access to the filesystem as another more low-level programming language might.  ?


----------



## ElDiabloConCaca (May 11, 2010)

Did you have a question about my post or something?


----------

