private static void OpenExportFolder(string sDirectory, string sFileName)
{
ProcessStartInfo processInfo = null;
if (Environment.OSVersion.Platform == PlatformID.Unix)
{
// if it exists, xdg-open uses the user's preference for opening directories
if (File.Exists("/usr/bin/xdg-open"))
{
processInfo = new ProcessStartInfo("/usr/bin/xdg-open", String.Format("\"{0}\"", sDirectory));
}
else if (File.Exists("/usr/bin/nautilus"))
{
processInfo = new ProcessStartInfo("/usr/bin/nautilus", String.Format("\"{0}\"", sDirectory));
}
else if (File.Exists("/usr/bin/krusader"))
{
processInfo = new ProcessStartInfo("/usr/bin/krusader", String.Format("\"{0}\"", sDirectory));
}
else if (File.Exists("/usr/bin/pcmanfm"))
{
processInfo = new ProcessStartInfo("/usr/bin/pcmanfm", String.Format("\"{0}\"", sDirectory));
}
else if (File.Exists("/usr/bin/gnome-commander"))
{
processInfo = new ProcessStartInfo("/usr/bin/gnome-commander",
String.Format("-l \"{0}\" -r \"{1}\"", Path.GetDirectoryName(sDirectory), sDirectory));
}
// If the user doesn't have one of these programs installed, I give up!
}
else
{
// REVIEW: What happens if directory or filename contain spaces?
var program = Environment.ExpandEnvironmentVariables(@"%WINDIR%\explorer.exe");
if (program == @"\explorer.exe")
program = @"C:\windows\explorer.exe";
if (String.IsNullOrEmpty(sFileName))
{
processInfo = new ProcessStartInfo(program, String.Format(" /select,{0}", sDirectory));
}
else
{
processInfo = new ProcessStartInfo(program, String.Format(" /select,{0}", sFileName));
}
}
if (processInfo != null)
{
using (Process.Start(processInfo))
{
}
}
}