public void Open(string path, TypeFile type) { FileState preview = State; if (!File.Exists(path)) { if (preview != FileState.OK) { State = FileState.FileNotExists; } string message = Words.Get(Key.FileNotExists); string caption = Words.Get(Key.Error); Err.Show(message, caption); return; } Path = path; string data = File.ReadAllText(Path); if (type == TypeFile.txt) { file = new TXT(data); } else { file = new TXT(DVPL.Parse(data)); } State = FileState.OK; }
public void Save() { if (State == FileState.OK) { if (type == TypeFile.txt) { File.WriteAllText(Path, file.ToString()); } else { File.WriteAllBytes(Path, DVPL.ToDVPL(file.ToString())); } } }
public void SaveAs(string path) { if (State == FileState.OK) { if (System.IO.Path.GetExtension(path) == "dvpl") { File.WriteAllBytes(path, DVPL.ToDVPL(file.ToString())); } else { File.WriteAllText(path, file.ToString()); } Path = path; } }