Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.53 KB | None | 0 0
  1. // get photo
  2. GraphServiceClient graphClient = GetAuthenticatedGraphClient(...);
  3. var requestUserPhotoFile = graphClient.Me.Photo.Content.Request();
  4. var resultUserPhotoFile = requestUserPhotoFile.GetAsync().Result;
  5.  
  6. // create the file
  7. var profilePhotoPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "profilePhoto_" + resultsUserPhoto.Id + ".jpg");
  8. var profilePhotoFile = System.IO.File.Create(profilePhotoPath);
  9. resultUserPhotoFile.Seek(0, System.IO.SeekOrigin.Begin);
  10. resultUserPhotoFile.CopyTo(profilePhotoFile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement