Exemplo n.º 1
0
 /**
  * <summary>
  * Get file information.
  * </summary>
  * <param name="path">Path to file.</param>
  * <exception cref='TerminalFileException'>Inaccessible path.</exception>
  * <returns>File information.</returns>
  */
 FileInfo GetFileInfo(string path)
 {
     try {
         return(new FileInfo(path));
     } catch (S.Exception error) {
         throw TerminalFileException.InaccessiblePath(path, error);
     }
 }
Exemplo n.º 2
0
 /**
  * <summary>Initialize properties about the application path and name, configuration path and file information, and main arguments.</summary>
  * <param name="arguments">Main arguments.</param>
  * <exception cref="TerminalFileException">Failure accessing application/configuration file information or current directory.</exception>
  */
 public Environment(SCG.IEnumerable <string> arguments)
 {
     try {
         WorkingDirectory = S.Environment.CurrentDirectory;
     } catch (S.Exception error) {
         throw TerminalFileException.CurrentDirectoryUnavailable(ConfigurationFilePath, error);
     }
     using (var currentProcess = SD.Process.GetCurrentProcess()) {
         ApplicationName      = currentProcess.ProcessName;
         using var mainModule = currentProcess.MainModule;
         // No exceptions should get thrown on a process necessarily running to execute this code.
         ApplicationFile = GetFileInfo(mainModule.FileName);
     }
     ApplicationDirectory  = ApplicationFile.DirectoryName;
     ConfigurationFilePath = SIO.Path.Combine(ApplicationDirectory, _configurationFileName);
     ConfigurationFile     = GetFileInfo(ConfigurationFilePath);
     Arguments             = arguments;
 }