예제 #1
0
        public bool saveProcesses(PSProcessCollection collection)
        {
            bool bRet = true;

            //ensure the directory exists

            try
            {
                if (!Directory.Exists(mAppDataDir))
                {
                    Directory.CreateDirectory(mAppDataDir);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message,
                                "Error saving mapping to disk",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            try
            {
                BinaryFormatter formatter = new BinaryFormatter();
                MemoryStream    ms        = new MemoryStream();
                formatter.Serialize(ms, collection);
                File.WriteAllBytes(mMapFilePath, ms.GetBuffer());
            }
            catch (Exception ex)
            {
                bRet = false;
            }

            return(bRet);
        }
예제 #2
0
        public PSProcessCollection loadProcesses()
        {
            PSProcessCollection ret = null;

            try
            {
                BinaryFormatter formatter = new BinaryFormatter();
                MemoryStream    ms        = new MemoryStream(File.ReadAllBytes(mMapFilePath));
                ret = (PSProcessCollection)formatter.Deserialize(ms);
            }
            catch (Exception ex)
            {
                ret = null;
            }

            return(ret);
        }
예제 #3
0
        private void loadMappings()
        {
            PSDB db = new PSDB();
            PSProcessCollection loadedData = db.loadProcesses();

            if (null == loadedData)
            {
                if (System.IO.File.Exists(db.mMapFilePath))
                {
                    MessageBox.Show(
                        "An error occured trying to load the saved mappings; this usually means corruption.",
                        "Loading saved mapping",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                mProcesses = loadedData;
            }
        }
예제 #4
0
 public frmAddMapping(PSProcessCollection existingProcesses)
 {
     InitializeComponent();
     mExistingProcesses = existingProcesses;
 }