PoEWhisperNotifier.LogMonitor.TryGetDefaultLogPath C# (CSharp) Method

TryGetDefaultLogPath() public static method

Attempts to location a default client.txt location, using either the standard installation path or the directory PoE is running frmo. Returns whether the client.txt was successfully located.
public static TryGetDefaultLogPath ( string &LogPath ) : bool
LogPath string
return bool
		public static bool TryGetDefaultLogPath(out string LogPath) {
			try {
				var PoeProc = Main.GetPoeProcess();
				string ExpectedPath;
				if (PoeProc != null)
					ExpectedPath = Path.Combine(Path.GetDirectoryName(PoeProc.MainModule.FileName), "logs", "Client.txt");
				else
					ExpectedPath = DEFAULT_LOG_PATH;
				if (IsValidLogPath(ExpectedPath)) {
					LogPath = ExpectedPath;
					return true;
				}
			} catch {
				// Ignore any failures as this is purely a convenience function and should not cause issues on failure.
			}
			LogPath = "";
			return false;
		}

Usage Example

コード例 #1
0
ファイル: Main.cs プロジェクト: chhe/PoEWhisperNotifier
 private void Form1_Load(object sender, EventArgs e)
 {
     NotificationIcon.Visible            = Settings.Default.TrayNotifications || Settings.Default.MinimizeToTray;
     NotificationIcon.BalloonTipClicked += NotificationIconClick;
     NotificationIcon.DoubleClick       += NotificationIconClick;
     txtLogPath.TextChanged             += txtLogPath_TextChanged;
     txtLogPath.Click += txtLogPath_Click;
     txtLogPath.Text   = Settings.Default.LogPath;
     // TODO: Most of these could be easily replaced with a method to map the toolstrip to the setting.
     tsmNotifyMinimizedOnly.Checked     = Settings.Default.NotifyMinimizedOnly;
     tsmEnableTrayNotifications.Checked = Settings.Default.TrayNotifications;
     tsmEnableSMTPNotifications.Checked = Settings.Default.EnableSmtpNotifications;
     tsmEnablePushBullet.Checked        = Settings.Default.EnablePushbullet;
     tsmEnableSound.Checked             = Settings.Default.EnableSound;
     tsmAutoStart.Checked        = Settings.Default.AutoStartWhenOpened;
     tsmMinimizeToTray.Checked   = Settings.Default.MinimizeToTray;
     tsmLogPartyMessages.Checked = Settings.Default.LogPartyMessages;
     this.Resize += Main_Resize;
     if (!LogMonitor.IsValidLogPath(txtLogPath.Text))
     {
         string DefaultLogPath;
         if (LogMonitor.TryGetDefaultLogPath(out DefaultLogPath))
         {
             txtLogPath.Text = DefaultLogPath;
         }
         else
         {
             AppendMessage("Unable to figure out client.txt location. You will have to manually set the path.");
         }
     }
     if (Settings.Default.AutoStartWhenOpened)
     {
         Start(true);
     }
 }