public static void Save(VkUser user) { if (user == null || user.UserId < 1L) return; string path = FileVk.Default.PathToSave + (object) Constant.UserFolder + "\\" + (string) (object) user.UserId + Constant.Extension; if (File.Exists(path)) return; string str = HelperToJson.ToJson(user); using (StreamWriter streamWriter = new StreamWriter((Stream) File.Create(path))) streamWriter.Write(str); }
public static void SaveHtmlPhoto(VkUser user) { string path = string.Format(FileVk.Default.PathToSave + Constant.UserFolder + "\\{0}-{1}-photo.html", (object) user.UserId, (object) user.LastName); if (File.Exists(path)) File.Delete(path); using (StreamWriter streamWriter = new StreamWriter((Stream) File.Create(path))) { if (user.Albums == null) return; foreach (VkAlbum vkAlbum in user.Albums) { if (vkAlbum.Photos == null) break; foreach (VkPhoto vkPhoto in vkAlbum.Photos) { if (vkPhoto != null && !string.IsNullOrEmpty(vkPhoto.SrcBig)) streamWriter.WriteLine("<img src={0} />", (object) vkPhoto.SrcBig); } } } }
public static string ToJson(VkUser user) { if (user == null) return string.Empty; return new JavaScriptSerializer().Serialize(user); }