I'm trying to make a Windows Phone 7 app that will save some images off the web, I have no idea where I can or if I can save images from the web to the phone.
What can I do to save images?
I'm trying to make a Windows Phone 7 app that will save some images off the web, I have no idea where I can or if I can save images from the web to the phone.
What can I do to save images?
On the phone, you can use HttbWebRequest (recommended to avoid UI impact) or WebClient per the project I posted here.
WebClient, HttpWebRequest and the UI Thread on Windows Phone 7
You can then take your stream and pass it into something of this form to write it to isolated storage.
Jon is correct you can also use MediaLibrary.SavePicture. Be aware that this would put the pics mixed in with the users photos in the Picture Hub.
This is as straight forward as
Storing it in isolated storage is basically your apps private file system.
You can download them using
WebClient
orWebRequest
to get the raw bytes.You can then save to isolated storage fairly easily - but I don't believe you can save in any location seen by the Picture hub, if that's what you were aiming for. (I can't see anything in the Microsoft.Phone.Tasks namespace which would be relevant. There are tasks to capture the camera of choose a photo, but not to save one.)
EDIT: Ooh, I've just found a way. You can use the MediaLibrary class and its SavePicture method... although that's in XNA, so I'd at least have concerns about it working from a Silverlight app. I know some bits of the XNA API do work from Silverlight, and some don't. Worth experimenting with.