Пример #1
0
        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;
        }
Пример #2
0
 public void Save()
 {
     if (State == FileState.OK)
     {
         if (type == TypeFile.txt)
         {
             File.WriteAllText(Path, file.ToString());
         }
         else
         {
             File.WriteAllBytes(Path, DVPL.ToDVPL(file.ToString()));
         }
     }
 }
Пример #3
0
 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;
     }
 }