Esempio n. 1
0
        /// <summary>
        /// Create an instance of the ConfigurationHelper with a specific location and filename for the INI
        /// </summary>
        /// <remarks>
        /// The INI will be stored in the given location with the given name.  If the Global or User Application Data folder is selected, the INI will be created in the Application.CompanyName subdirectory.
        /// </remarks>
        protected ConfigHelper(ConfigSaveLocation saveLocation, string fileName)
        {
            SectionName = "CONFIGURATION";

            IniPassword            = new RMSecureString();
            Loaded                 = false;
            RMSecureStringPassword = new RMSecureString();

            switch (saveLocation)
            {
            case ConfigSaveLocation.Absolute:
                FileName = fileName;
                break;

            case ConfigSaveLocation.GlobalApplicationData:
                FileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ProcessUtils.CompanyName, fileName);
                break;

            case ConfigSaveLocation.Relative:
                FileName = StringUtils.PathCombine(ProcessUtils.StartupPath, fileName);
                break;

            case ConfigSaveLocation.UserApplicationData:
                FileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ProcessUtils.CompanyName, fileName);
                break;
            }
        }
Esempio n. 2
0
        protected void MoveTo(ConfigSaveLocation saveLocation, string fileName)
        {
            string NewFileName = "";

            switch (saveLocation)
            {
            case ConfigSaveLocation.Absolute:
                NewFileName = fileName;
                break;

            case ConfigSaveLocation.GlobalApplicationData:
                NewFileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ProcessUtils.CompanyName, fileName);
                break;

            case ConfigSaveLocation.Relative:
                NewFileName = StringUtils.PathCombine(ProcessUtils.StartupPath, fileName);
                break;

            case ConfigSaveLocation.UserApplicationData:
                NewFileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ProcessUtils.CompanyName, fileName);
                break;
            }

            // If there's a source file, then move it to the new destination
            if (File.Exists(FileName))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(NewFileName));
                FileUtils.FileMove(FileName, NewFileName);
            }

            FileName = NewFileName;
        }
Esempio n. 3
0
 /// <summary>
 /// Create an instance of the ConfigurationHelper with a specific location for the INI to be saved
 /// </summary>
 /// <remarks>
 /// The INI will be stored in the requested location with the Application.ProductName as the file name.  If the Global or User Application Data folder is selected, the INI will be created in the Application.CompanyName subdirectory.
 /// </remarks>
 protected ConfigHelper(ConfigSaveLocation saveLocation) : this(saveLocation, ProcessUtils.ProductName + ".ini")
 {
 }
Esempio n. 4
0
 /// <summary>
 /// Create an instance of the ConfigurationHelper with a specific location for the INI to be saved
 /// </summary>
 /// <remarks>
 /// The INI will be stored in the requested location with the Application.ProductName as the file name.  If the Global or User Application Data folder is selected, the INI will be created in the Application.CompanyName subdirectory.
 /// </remarks>
 protected ConfigHelper(ConfigSaveLocation saveLocation)
     : this(saveLocation, ProcessUtils.ProductName + ".ini")
 {
 }
Esempio n. 5
0
        protected void MoveTo(ConfigSaveLocation saveLocation, string fileName)
        {
            string NewFileName = "";

            switch (saveLocation)
            {
                case ConfigSaveLocation.Absolute:
                    NewFileName = fileName;
                    break;
                case ConfigSaveLocation.GlobalApplicationData:
                    NewFileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ProcessUtils.CompanyName, fileName);
                    break;
                case ConfigSaveLocation.Relative:
                    NewFileName = StringUtils.PathCombine(ProcessUtils.StartupPath, fileName);
                    break;
                case ConfigSaveLocation.UserApplicationData:
                    NewFileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ProcessUtils.CompanyName, fileName);
                    break;
            }

            // If there's a source file, then move it to the new destination
            if (File.Exists(FileName))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(NewFileName));
                FileUtils.FileMove(FileName, NewFileName);
            }

            FileName = NewFileName;
        }
Esempio n. 6
0
        /// <summary>
        /// Create an instance of the ConfigurationHelper with a specific location and filename for the INI
        /// </summary>
        /// <remarks>
        /// The INI will be stored in the given location with the given name.  If the Global or User Application Data folder is selected, the INI will be created in the Application.CompanyName subdirectory.
        /// </remarks>
        protected ConfigHelper(ConfigSaveLocation saveLocation, string fileName)
        {
            SectionName = "CONFIGURATION";

            IniPassword = new RMSecureString();
            Loaded = false;
            RMSecureStringPassword = new RMSecureString();

            switch (saveLocation)
            {
                case ConfigSaveLocation.Absolute:
                    FileName = fileName;
                    break;
                case ConfigSaveLocation.GlobalApplicationData:
                    FileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), ProcessUtils.CompanyName, fileName);
                    break;
                case ConfigSaveLocation.Relative:
                    FileName = StringUtils.PathCombine(ProcessUtils.StartupPath, fileName);
                    break;
                case ConfigSaveLocation.UserApplicationData:
                    FileName = StringUtils.PathCombine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ProcessUtils.CompanyName, fileName);
                    break;
            }
        }