Пример #1
0
        public bool Save(CodeNowScript script, bool askForLocation)
        {
            string destination = script.Location;

            if (string.IsNullOrEmpty(destination) || askForLocation)
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = "All Files|*.*";
                sfd.Title  = "Save File";
                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    destination = sfd.FileName;
                }
                else
                {
                    destination = null;
                }
            }

            if (destination != null)
            {
                System.IO.File.WriteAllText(destination, script.GetString());
                script.Location      = destination;
                script.SourceStorage = this;
            }
            return(destination != null);
        }
Пример #2
0
        public CodeNowScript Open()
        {
            CodeNowScript  result = null;
            OpenFileDialog ofd    = new OpenFileDialog();

            ofd.Filter = "All Files|*.*";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                System.IO.StreamReader sr = new
                                            System.IO.StreamReader(ofd.FileName);
                string s = sr.ReadToEnd();
                sr.Close();
                result          = new CodeNowScript(s);
                result.Location = ofd.FileName;
            }

            return(result);
        }
Пример #3
0
 public bool Save(CodeNowScript script, bool askForLocation)
 {
     throw new Exception("Save not supported! Choose a different storage.");
 }