コード例 #1
0
        /// <summary>Opens a directory in Windows Explorer</summary>
        public static void OpenDirectory(string path)
        {
            if (path == string.Empty)
            {
                NotificationUtility.ShowError("Directory doesn't exist.");
                return;
            }
            DirectoryInfo diDir = new DirectoryInfo(path);

            if (diDir.Exists)
            {
                Process.Start(path);
            }
            else
            {
                NotificationUtility.ShowError($"Directory ({path}) doesn't exist.");
            }
        }
コード例 #2
0
 public static void OpenFile(string path, bool openAsReadOnly, int lineNumber)
 {
     if (File.Exists(path))
     {
         var p = new Process();
         p.StartInfo = new ProcessStartInfo()
         {
             UseShellExecute = false,
             FileName        = @"C:\Program Files\Notepad++\notepad++.exe",
             Arguments       = $"{(openAsReadOnly ? "-ro" : string.Empty)} \"{path}\" {(lineNumber > 0 ? "-n" + lineNumber : string.Empty)}"
         };
         p.Start();
     }
     else
     {
         NotificationUtility.ShowError("File doesn't exist.");
     }
 }