private static void loadCurrentLibrary() { string[] files = Directory.GetFiles(Engine.SlideDirectory, "*.sld", SearchOption.TopDirectoryOnly); currentLibrary = new string[files.Length]; EditableSlideSet temp; for (int x = 0; x < files.Length; x++) { temp = new EditableSlideSet(files[x]); currentLibrary[x] = temp.ToString(); } }
public static void ExportLibrary(string libraryPath, string[] fileToInclude) { BinaryWriter writer = new BinaryWriter(new FileStream(libraryPath, FileMode.Create)); writer.Write(slmFileVersion); writer.Write(fileToInclude.Length); EditableSlideSet[] temp = new EditableSlideSet[fileToInclude.Length]; for (int x = 0; x < fileToInclude.Length; x++) { temp[x] = new EditableSlideSet(fileToInclude[x]); writer.Write(temp[x].Name); } for (int x = 0; x < fileToInclude.Length; x++) { temp[x].loadFile(); writer.Write(temp[x].getWriteText()); } writer.Flush(); writer.Close(); }
public static void ImportSetsFromLibrary(string libraryPath, string[] sets) { BinaryReader reader = new BinaryReader(new FileStream(libraryPath, FileMode.Open)); reader.ReadByte(); int count = reader.ReadInt32(); //The contents table has already been read, so we can skip it. for (int x = 0; x < count; x++) { reader.ReadString(); } string[] xml = new string[count]; for (int x = 0; x < count; x++) { xml[x] = reader.ReadString(); } reader.Close(); bool yes = false; bool no = false; //OverwriteForm of = new OverwriteForm(); string temppath = Path.Combine(Engine.DataDirectory, "temp.sld"); for (int x = 0; x < count; x++) { StreamWriter tempout = new StreamWriter(new FileStream(temppath, FileMode.Create)); tempout.Write(xml[x]); tempout.Flush(); tempout.Close(); EditableSlideSet tempess = new EditableSlideSet(temppath); tempess.loadFile(); tempess.resetPath(); if (((IList <string>)sets).Contains(tempess.Name)) { if (File.Exists(tempess.Path)) { if (yes) { tempess.Write(); addToLibrary(tempess.Name); } else if (no) { } else { //of.setSongName(tempess.Name); switch (Engine.ShowConfirmDialog(tempess.Name)) //of.ShowDialog()) { case 0: //System.Windows.Forms.DialogResult.Retry: yes = true; tempess.Write(); addToLibrary(tempess.Name); break; case 1: //System.Windows.Forms.DialogResult.Yes: tempess.Write(); addToLibrary(tempess.Name); break; case 2: //System.Windows.Forms.DialogResult.Abort: no = true; break; case 3: //System.Windows.Forms.DialogResult.No: break; } } } else { tempess.Write(); addToLibrary(tempess.Name); } } File.Delete(temppath); } }