Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (record.CardFrontImage == null)
- {
- record.CardImage = record.CardBackImage;
- }
- else
- {
- record.CardImage = record.CardFrontImage;
- }
- string baseimage = Convert.ToBase64String(record.CardImage);
- var vcf = new StringBuilder(); //vcf code start
- vcf.AppendLine("BEGIN:VCARD");
- vcf.AppendLine("VERSION:3.0");
- vcf.AppendLine($"N:{record.ContactName};{string.Empty}; ;;");
- vcf.AppendLine($"FN:{record.ContactName}");
- vcf.AppendLine($"ORG:{record.CompanyName}");
- vcf.AppendLine($"TITLE:{record.Designation}");
- vcf.AppendLine($"PHOTO;ENCODING=BASE64;TYPE=PNG:{baseimage}");
- vcf.AppendLine($"TEL;TYPE=work,voice;VALUE=uri:tel:{record.PhoneNumber}");
- vcf.AppendLine("END:VCARD");
- string fileName = Path.Combine("/storage/emulated/0/Android/data/com.Gamma.GammaNetworkingApp/files/", record.ContactID + record.ContactName + ".vcf");
- using (var writer = new StreamWriter(fileName))
- {
- writer.Write(vcf.ToString());
- }
- string text = File.ReadAllText(fileName);
- bool doesExist = File.Exists(fileName);
- if (doesExist == true)
- {
- var share = DependencyService.Get<IShare>();
- share.Show("Contact share", record.ContactName, fileName);
- }
- }
- catch (Exception ex)
- {
- string test = ex.ToString();
- Navigation.PushAsync(new HomePage());
- }
- }
Add Comment
Please, Sign In to add comment