SIL.Core/IO/PathUtilities.cs
/// <summary>
/// On Windows this selects the file or directory in Windows Explorer; on Linux it selects the file
/// in the default file manager if that supports selecting a file and we know it,
/// otherwise we fall back to xdg-open and open the directory that contains that file.
/// </summary>
/// <param name="path">File or directory path.</param>
On Windows this selects the file or directory in Windows Explorer; on Linux it selects the file
in the default file manager if that supports selecting a file and we know it,
otherwise we fall back to xdg-open and open the directory that contains that file.
On Windows this selects the file or directory in Windows Explorer ; on Linux it selects the file in the default file manager if that supports selecting a file and we know it otherwise we fall back to xdg - open and open the directory that contains that file .
public static void SelectFileInExplorer(string path)
		{
			if (Platform.IsWindows)
			{
				var pidlList = ILCreateFromPathW(path);
				if(pidlList == IntPtr.Zero)
					throw new Exception(string.Format("ILCreateFromPathW({0}) failed", path));
				try
				{
					Marshal.ThrowExceptionForHR(SHOpenFolderAndSelectItems(pidlList, 0, IntPtr.Zero, 0));
				}
				finally
				{
					ILFree(pidlList);
				}
			}
			else
			{
				var fileManager = DefaultFileManager;
				string arguments;
				switch (fileManager)
				{
					case "nautilus":
					case "nemo":
						arguments = string.Format("\"{0}\"", path);
						break;
					default:
						fileManager = "xdg-open";
						arguments = string.Format("\"{0}\"", Path.GetDirectoryName(path));
						break;
				}
				Process.Start(fileManager, arguments);
			}
		}
public static void SelectFileInExplorer ( string path ) { if ( Platform . IsWindows ) { var pidlList = ILCreateFromPathW ( path ) ; if ( pidlList == IntPtr . Zero ) throw new Exception ( string . Format ( " " , path ) ) ; try { Marshal . ThrowExceptionForHR ( SHOpenFolderAndSelectItems ( pidlList , 0 , IntPtr . Zero , 0 ) ) ; } finally { ILFree ( pidlList ) ; } } else { var fileManager = DefaultFileManager ; string arguments ; switch ( fileManager ) { case " " : case " " : arguments = string . Format ( " \" \" " , path ) ; break ; default : fileManager = " " ; arguments = string . Format ( " \" \" " , Path . GetDirectoryName ( path ) ) ; break ; } Process . Start ( fileManager , arguments ) ; } }
On Windows this selects the file or directory in Windows Explorer; on Linux it selects the file
in the default file manager if that supports selecting a file and we know it,
otherwise we fall back to xdg-open and open the directory that contains that file.
On Windows this selects the file or directory in Windows Explorer ; on Linux it selects the file in the default file manager if that supports selecting a file and we know it otherwise we fall back to xdg - open and open the directory that contains that file .
//we need to use this becuase of a bug in windows that strips composed characters before trying to find the target path (http://stackoverflow.com/a/30405340/723299)
path
string
File or directory path.
File or directory path .