//public OpenWithItemCommandModel(Profile<FI, DI, FSI> profile, // FileModel<FI, DI, FSI> appliedEntryModel) //{ // _profile = profile; // _appliedEntryModel = appliedEntryModel; // IsExecutable = true; // Header = Texts.strChooseDefaultProgram; //} public OpenWithItemCommandModel(Profile <FI, DI, FSI> profile, EntryModel <FI, DI, FSI> appliedEntryModel, OpenWithInfo info) { _profile = profile; _appliedEntryModel = appliedEntryModel; _info = info; IsExecutable = true; if (info != null && !info.Equals(OpenWithInfo.OpenAs)) { string exePath = OpenWithInfo.GetExecutablePath(info.OpenCommand); if (File.Exists(exePath)) { HeaderIcon = _profile.IconExtractor.GetIcon(exePath, Converters.IconSize.small, false); } if (File.Exists(exePath)) { FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(exePath); if (fvi.ProductName.EndsWith("Operating System")) //WordPad / NotePad { Header = fvi.FileDescription; } Header = fvi.ProductName; } } else { Header = Texts.strChooseDefaultProgram; } }
public virtual void Open(FI entry, OpenWithInfo openInfo = null) { string diskPath = GetDiskPath(entry); ProcessStartInfo psi = null; if (File.Exists(diskPath)) { if (openInfo != null) { if (!openInfo.Equals(OpenWithInfo.OpenAs)) { psi = new ProcessStartInfo(OpenWithInfo.GetExecutablePath(openInfo.OpenCommand), diskPath); } else { //http://bytes.com/topic/c-sharp/answers/826842-call-windows-open-dialog psi = new ProcessStartInfo("Rundll32.exe"); psi.Arguments = String.Format(" shell32.dll, OpenAs_RunDLL {0}", diskPath); } } else { psi = new ProcessStartInfo(diskPath); } } if (psi != null) { try { Process.Start(psi); } catch (Exception ex) { Debug.WriteLine(ex.Message); } } }