mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 10:47:02 -07:00
Added logic which forces the greenshot.ini to be created in the startup-path (where the executable is) when there is no log4net.xml available. This is useful when someone just wants to use the greenshot.exe
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1607 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
89c2b7a9e7
commit
83570e855b
4 changed files with 28 additions and 5 deletions
|
@ -48,6 +48,7 @@ namespace IniFile {
|
|||
return portable;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the ini config
|
||||
/// </summary>
|
||||
|
@ -59,7 +60,25 @@ namespace IniFile {
|
|||
Reload();
|
||||
WatchConfigFile(true);
|
||||
}
|
||||
|
||||
|
||||
public static void ForceIniInStartupPath() {
|
||||
if (portableCheckMade) {
|
||||
throw new Exception("ForceLocal should be called before any file is read");
|
||||
}
|
||||
portable = false;
|
||||
portableCheckMade = true;
|
||||
string applicationStartupPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
|
||||
if (applicationName == null || configName == null) {
|
||||
Init();
|
||||
}
|
||||
string forcedIni = Path.Combine(applicationStartupPath, applicationName + INI_EXTENSION);
|
||||
if (!File.Exists(forcedIni)) {
|
||||
using (File.Create(forcedIni)) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default init
|
||||
/// </summary>
|
||||
|
@ -87,7 +106,7 @@ namespace IniFile {
|
|||
// Monitor the ini file
|
||||
watcher = new FileSystemWatcher();
|
||||
watcher.Path = Path.GetDirectoryName(iniLocation);
|
||||
watcher.Filter = "*.ini";
|
||||
watcher.Filter = "greenshot.ini";
|
||||
watcher.NotifyFilter = NotifyFilters.LastWrite;
|
||||
watcher.Changed += new FileSystemEventHandler(ConfigFileChanged);
|
||||
}
|
||||
|
@ -158,7 +177,9 @@ namespace IniFile {
|
|||
if (portable) {
|
||||
string pafConfigPath = Path.Combine(applicationStartupPath, @"Data\Settings");
|
||||
try {
|
||||
Directory.CreateDirectory(pafConfigPath);
|
||||
if (!Directory.Exists(pafConfigPath)) {
|
||||
Directory.CreateDirectory(pafConfigPath);
|
||||
}
|
||||
iniFilePath = Path.Combine(pafConfigPath, configFilename);
|
||||
} catch(Exception e) {
|
||||
LOG.InfoFormat("Portable mode NOT possible, couldn't create directory '{0}'! Reason: {1}", pafConfigPath, e.Message);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue