Пример #1
0
        internal static ProjectUserFile OpenProjectUserFile(string filePath)
        {
            if (System.IO.File.Exists(filePath)){

                try{

                    using (FileStream fs = File.OpenRead(filePath)) {
                        XmlSerializer serializer = new XmlSerializer(typeof(ProjectUserFile));

                    ProjectUserFile p = (ProjectUserFile)serializer.Deserialize(fs);
                        p.FilePath = filePath;

                    return p;
                    }
                }catch{//(Exception ex){

                    ProjectUserFile p =new ProjectUserFile(filePath);
                    return p;
                    /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.OkCancel, MainClass.Languages.Translate("project_is_corrupted", filePath), MainClass.Languages.Translate("delete_corupted_project"), Gtk.MessageType.Question,null);
                    int res = md.ShowDialog();
                    return null;*/

                }
            }else {
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_not_exit_f1", filePath), "", Gtk.MessageType.Error,null);
                md.ShowDialog();
                return null;
            }
        }
Пример #2
0
        static internal ProjectUserFile OpenProjectUserFile(string filePath)
        {
            if (System.IO.File.Exists(filePath))
            {
                try{
                    using (FileStream fs = File.OpenRead(filePath)) {
                        XmlSerializer serializer = new XmlSerializer(typeof(ProjectUserFile));

                        ProjectUserFile p = (ProjectUserFile)serializer.Deserialize(fs);
                        p.FilePath = filePath;

                        return(p);
                    }
                }catch {               //(Exception ex){
                    ProjectUserFile p = new ProjectUserFile(filePath);
                    return(p);

                    /*MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.OkCancel, MainClass.Languages.Translate("project_is_corrupted", filePath), MainClass.Languages.Translate("delete_corupted_project"), Gtk.MessageType.Question,null);
                     * int res = md.ShowDialog();
                     * return null;*/
                }
            }
            else
            {
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("project_not_exit_f1", filePath), "", Gtk.MessageType.Error, null);
                md.ShowDialog();
                return(null);
            }
        }