public PhoneBook[] GetPhoneBooks(PbapFolder Folder, int MaxNum) { List <PhoneBook> phoneBookList = new List <PhoneBook>(); var t = Task.Factory.StartNew(() => { int length = GetPhoneBookCount(Folder); if (MaxNum > 0) { length = Math.Min(length, MaxNum); } for (int i = 0; i < length; i += 10) { using (ObexGetStream Stream = PullPhoneBook(Folder, 10, i)) { byte[] ba = new byte[UInt16.MaxValue]; int readSize = Stream.Read(ba, 0, UInt16.MaxValue); phoneBookList.AddRange(VCardReader.ParseVCard(UTF8Encoding.UTF8.GetString(ba, 0, readSize))); } } SessionConnect(); }); t.Wait(); return(phoneBookList.ToArray()); }
private PhoneBook GetPhoneBook(PbapFolder Folder, string handle) { using (ObexGetStream Stream = PullvCardEntry(Folder, handle)) { byte[] ba = new byte[UInt16.MaxValue]; int readSize = Stream.Read(ba, 0, UInt16.MaxValue); List <PhoneBook> phoneBookList = VCardReader.ParseVCard(UTF8Encoding.UTF8.GetString(ba, 0, readSize)); if (phoneBookList.Count > 0) { return(phoneBookList[0]); } } return(null); }