Try the following.

Tips:
-You can change the ImageFormat to whatever you want. Remember to
update the filename extension.
-Make sure you have permission to write to the path you specify. To
test, just put a filename and it'll write to the path of the
executable.

if (entry.PhotoUri != null)
{
    try
    {
        Stream s = service.Query(entry.PhotoUri);
        Image image = Image.FromStream(s);
        image.Save("c:\path\to\save\folder\filename.jpg",
ImageFormat.Jpeg);
    }
    catch (Exception)
    {
        //no picture found
    }
}

-Jesse



On Dec 21, 10:40 pm, Alex Launi <[email protected]> wrote:
> Hi, I'm trying to get a local copy of a contacts photo but I cannot
> for the life of me figure out how to get it.
>
> try {
>         if (entry.PhotoUri != null) {
>                 using (MemoryStream ms = service.Query (entry.PhotoUri) as
> MemoryStream) {
>                         if (ms == null) Log.Error ("I'M SHOOTING BLANKS!");
>                         else File.WriteAllBytes (string.Format 
> ("/home/alex/Desktop/pics/
> {0}", entry.Title.Text), ms.ToArray ());
>                 }
>         }} catch (Exception e) {
>
>         Log.Error (e.Message);
>
> }
>
> That's what I've most recently tried but it is still not working,
> wgetting the Uri just gives me an empty file, what is the secret! It's
> well guarded apparently. Thanks to anyone who can help me with this
> deceivingly simple problem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to