Guest User

Untitled

a guest
Dec 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. if (record.CardFrontImage == null)
  2. {
  3. record.CardImage = record.CardBackImage;
  4. }
  5. else
  6. {
  7. record.CardImage = record.CardFrontImage;
  8. }
  9.  
  10. string baseimage = Convert.ToBase64String(record.CardImage);
  11.  
  12. var vcf = new StringBuilder(); //vcf code start
  13. vcf.AppendLine("BEGIN:VCARD");
  14. vcf.AppendLine("VERSION:3.0");
  15. vcf.AppendLine($"N:{record.ContactName};{string.Empty}; ;;");
  16. vcf.AppendLine($"FN:{record.ContactName}");
  17. vcf.AppendLine($"ORG:{record.CompanyName}");
  18. vcf.AppendLine($"TITLE:{record.Designation}");
  19. vcf.AppendLine($"PHOTO;ENCODING=BASE64;TYPE=PNG:{baseimage}");
  20. vcf.AppendLine($"TEL;TYPE=work,voice;VALUE=uri:tel:{record.PhoneNumber}");
  21.  
  22. vcf.AppendLine("END:VCARD");
  23.  
  24. string fileName = Path.Combine("/storage/emulated/0/Android/data/com.Gamma.GammaNetworkingApp/files/", record.ContactID + record.ContactName + ".vcf");
  25.  
  26. using (var writer = new StreamWriter(fileName))
  27. {
  28. writer.Write(vcf.ToString());
  29. }
  30.  
  31. string text = File.ReadAllText(fileName);
  32.  
  33. bool doesExist = File.Exists(fileName);
  34.  
  35. if (doesExist == true)
  36. {
  37. var share = DependencyService.Get<IShare>();
  38. share.Show("Contact share", record.ContactName, fileName);
  39. }
  40. }
  41. catch (Exception ex)
  42. {
  43. string test = ex.ToString();
  44. Navigation.PushAsync(new HomePage());
  45. }
  46. }
Add Comment
Please, Sign In to add comment