示例#1
0
        public static TryGetLogPath1C GetLogPath1C()
        {
            if (string.IsNullOrEmpty(ExePath1C))
            {
                string msg = "Отсутствует путь к исполняемуом файлу 1С";
                NLogger.LogErrorToHdd(msg);
                return(new TryGetLogPath1C(false, msg));
            }

            string logs = Path.Combine(Path.GetTempPath(), "1CLogsForMagicUpdater");

            if (!Directory.Exists(logs))
            {
                try
                {
                    Directory.CreateDirectory(logs);
                }
                catch (Exception ex)
                {
                    NLogger.LogErrorToHdd(ex.Message.ToString());
                    return(new TryGetLogPath1C(false, ex.Message.ToString()));
                }
            }
            try
            {
                Extensions.AddDirectorySecurity(logs, System.Security.Principal.WindowsIdentity.GetCurrent().Name, System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow);
            }
            catch (Exception ex)
            {
                NLogger.LogErrorToHdd(ex.Message.ToString());
                return(new TryGetLogPath1C(false, ex.Message.ToString()));
            }

            LogPath1C = Path.Combine(logs, "OutLog.log");

            return(new TryGetLogPath1C());
        }