Nandaka / NijieDownloader

nijie.info downloader
http://nandaka.devnull.zone/
60 stars 8 forks source link

[1.0.1.0] Request: keep the settings file in the same folder #12

Closed reyaz006 closed 10 years ago

reyaz006 commented 10 years ago

Because when a full reset is needed, having to go to C:\Users\User\AppData\Local\Nandaka\NijieDownloader.UI.exe_Url_tonsofrandomsymbols\1.0.1.0 is not very comfortable. This should also make the app fully portable.

Nandaka commented 10 years ago

No easy way to do this as this is the behaviour of .Net configuration.

reyaz006 commented 10 years ago

Then maybe implement a function to wipe all settings from within the app?

Nandaka commented 10 years ago

For reference

ConfigurationUserLevel[] options = { ConfigurationUserLevel.PerUserRoaming, ConfigurationUserLevel.PerUserRoamingAndLocal };

            foreach (var item in options)
            {
                var config = ConfigurationManager.OpenExeConfiguration(item);
                if (File.Exists(config.FilePath))
                {
                    Debug.WriteLine(config.FilePath);
                    // Delete the folder where app.config resides, e.g. /Nandaka/NijieDownloader_xxxx/
                    new FileInfo(config.FilePath).Directory.Parent.Delete(true);
                    try
                    {
                        // Delete the root folder, e.g. /Nandaka/.. if empty
                        new FileInfo(config.FilePath).Directory.Parent.Parent.Delete(false);
                    }
                    catch (Exception ex) { Debug.WriteLine(ex.Message); }
                }
            }
            Properties.Settings.Default.Reload();