public bool LoadUIL(string folderPath) { bool result = false; List <uint> ids = new List <uint>(); List <string> types = new List <string>(); List <DateTime> dates = new List <DateTime>(); List <uint> originalSourceIds = new List <uint>(); List <string> names = new List <string>(); List <string> libraryPaths = new List <string>(); List <string> dataPaths = new List <string>(); string libFileName = folderPath + "Library.xml"; FileStream fs = new FileStream(libFileName, FileMode.Open); XmlTextReader r = new XmlTextReader(fs); r.WhitespaceHandling = WhitespaceHandling.None; r.ReadStartElement("Library"); do { if (r.IsStartElement()) { switch (r.Name) { case "LibraryIdCounter": if (r.Read()) { definitionIdCounter = uint.Parse(r.Value.Trim(), NumberStyles.Any); r.Read(); } break; case "LibraryItems": while (r.Read()) { if (r.IsStartElement() && r.Name == "Item") { ids.Add(uint.Parse(r.GetAttribute("Id"), CultureInfo.InvariantCulture)); types.Add(r.GetAttribute("Type")); dates.Add(DateTime.ParseExact(r.GetAttribute("Date"), "u", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal)); string osid = r.GetAttribute("OriginalSourceId"); if (osid != null) { uint orgId; uint.TryParse(osid, out orgId); originalSourceIds.Add(orgId); } else { originalSourceIds.Add(0); } names.Add(r.GetAttribute("Name")); dataPaths.Add(r.GetAttribute("DataPath")); libraryPaths.Add(r.GetAttribute("LibraryPath")); } } break; default: r.Read(); break; } } }while (r.Read()); r.Close(); fs.Close(); // read actual library Items for (int i = 0; i < ids.Count; i++) { string dp = folderPath + dataPaths[i]; string type = types[i]; LibraryItem li = LibraryItem.LoadFromPath(stage, type, dp); if (li != null) // todo: account for missing files { li.Name = names[i]; li.OriginalSourceId = originalSourceIds[i]; li.Date = dates[i]; li.LibraryPath = libraryPaths[i]; AddLibraryItem(li); li.HasSaveableChanges = false; } } hasSaveableChanges = false; return(result); }