PathHelper.cs 780 B

123456789101112131415161718192021222324252627
  1. using System;
  2. using System.IO;
  3. namespace BanTur.Utility
  4. {
  5. public static class PathHelper
  6. {
  7. public static string DbFilePath
  8. {
  9. get
  10. {
  11. var env = Environment.GetEnvironmentVariable(BanTurRuntime.EnvVarDbPath);
  12. if (!string.IsNullOrWhiteSpace(env))
  13. {
  14. if (Directory.Exists(Path.GetDirectoryName(env))) return env;
  15. }
  16. var exePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
  17. var exeDir = Path.GetDirectoryName(exePath);
  18. var fileName = Path.ChangeExtension(Path.GetFileName(exePath), "db3");
  19. return Path.Combine(exeDir, fileName);
  20. }
  21. }
  22. }
  23. }