Ejemplo n.º 1
0
        public Archivist(IFileProvider fileProvider, ILogMachine logMachine)
        {
            _fileProvider = fileProvider;
            _logger       = logMachine;

            //this will get the folder from which the code is executed.
            //our code should use that path and search inside if the needed folders exists.

            var current = AssemblyLocator.GetAssemblyLocation();

            _logger.Log($"Archivist looking inside {current} for required folders...");

            var directories = Directory.GetDirectories(current);

            Directory.CreateDirectory(Path.Combine(current, "CharacterSheets"));
            _logger.Log($"Archivist created Character Sheet folder");

            sheetPath = Path.GetFullPath(Path.Combine(current, "CharacterSheets"));

            var archiveFolder = directories.FirstOrDefault(x => x == "Archives");

            Directory.CreateDirectory(Path.Combine(current, "Archives"));
            _logger.Log($"Archivist created Archives folder");
            archivePath = Path.GetFullPath(Path.Combine(current, "Archives"));

            _logger.Log($"Characters will be saved in {sheetPath} and archived in {archivePath} .");
        }
Ejemplo n.º 2
0
        public LogMachine(IFileProvider fileProvider)
        {
            _fileProvider = fileProvider;
            string logFolderPath = "";

            var assemblyPath = AssemblyLocator.GetAssemblyLocation();

            var logFolder = Directory.GetDirectories(assemblyPath).FirstOrDefault(x => x == "logfolder");

            //var logFolder = _fileProvider.GetDirectoryContents("").FirstOrDefault(x => x.Name == "logFolder");

            if (logFolder == null)
            {
                Directory.CreateDirectory(Path.Combine(assemblyPath, "logFolder"));
            }

            logFolderPath = Path.GetFullPath(Path.Combine(assemblyPath, "logFolder"));

            logFile = Path.Combine(logFolderPath, "log.txt");

            if (!File.Exists(logFile))
            {
                File.Create(logFile).Close();
            }
        }