public void LoadPhotos() { int selectedIndex = 0; if (photosLV.SelectedIndices.Count > 0) { selectedIndex = photosLV.SelectedIndices[0]; } photosLV.Items.Clear(); _photos = Photo.FindAll(); double bytes = 0; foreach (Photo p in _photos) { string[] items = { p.Name, p.Time.ToLongTimeString(), p.Caption }; ListViewItem lvi = new ListViewItem(items); photosLV.Items.Add(lvi); bytes = bytes + p.Jpg.Length; } if (photosLV.Items.Count > 0) { if (selectedIndex < photosLV.Items.Count) { photosLV.Items[selectedIndex].Selected = true; } else { photosLV.Items[photosLV.Items.Count - 1].Selected = true; } } if (bytes > (1024.0 * 1024.0 * 1024.0)) { sizeLBL.Text = string.Format(" Total Photo Size: {0:f} gb", bytes / (1024.0 * 1024.0 * 1024.0)); } else if (bytes > (1024.0 * 1024.0)) { sizeLBL.Text = string.Format(" Total Photo Size: {0:f} mb", bytes / (1024.0 * 1024.0)); } else if (bytes > (1024.0)) { sizeLBL.Text = string.Format(" Total Photo Size: {0:f} kb", bytes / (1024.0)); } else { sizeLBL.Text = string.Format(" Total Photo Size: {0:f} b", bytes); } }