using System; using System.IO; namespace BMS_D1000H.Utils.Functions { public static class PathHelper { private static string _basePath = null; public static string BasePath { get { if (_basePath == null) { // Flash Disk가 디바이스 환경에 존재하는 경우 우선 사용, 그렇지 않은 경우 애플리케이션 실행 디렉터리로 Fallback if (Directory.Exists(@"Flash Disk")) { _basePath = @"Flash Disk\Run"; } else { string appDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); _basePath = Path.Combine(appDir, "Run"); } } return _basePath; } } public static string GetFullPath(string fileNameOrSubPath) { string fullPath = Path.Combine(BasePath, fileNameOrSubPath); string dir = Path.GetDirectoryName(fullPath); if (!string.IsNullOrEmpty(dir) && !Directory.Exists(dir)) { try { Directory.CreateDirectory(dir); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Directory Creation Error: " + ex.Message); } } return fullPath; } } }