Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static string GetPath(string extension)
- {
- try
- {
- var openSubKey = Registry.ClassesRoot.OpenSubKey(extension);
- if (openSubKey != null)
- {
- var appName = (string)openSubKey.GetValue(null);
- var registryKey = Registry.ClassesRoot.OpenSubKey(appName + @"\shell\open\command");
- if (registryKey != null)
- {
- var openWith =
- (string)
- registryKey.GetValue(null);
- var appPath = openWith.Substring(1, openWith.Length - 1);
- var max = appPath.LastIndexOf(".exe", StringComparison.Ordinal);
- if (max < 1)
- max = appPath.Length;
- appPath = appPath.Substring(0, max + 4);
- return new FileInfo(appPath).FullName;
- }
- }
- }
- catch
- {
- return "";
- }
- return null;
- }
- var unpacker = GetPath(".rar")
Add Comment
Please, Sign In to add comment