mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Add try, finally to SHOpenFolderAndSelectItems
This commit is contained in:
parent
3425e167db
commit
a8636cbf39
1 changed files with 9 additions and 6 deletions
|
@ -477,15 +477,18 @@ public static bool FlashWindowEx(Form frm, uint flashCount = uint.MaxValue)
|
|||
return FlashWindowEx(ref fInfo);
|
||||
}
|
||||
|
||||
// http://stackoverflow.com/questions/14600987/code-to-open-windows-explorer-or-focus-if-exists-with-file-selected
|
||||
public static void OpenFolderAndSelectFile(string filePath)
|
||||
{
|
||||
if (filePath == null)
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
|
||||
IntPtr pidl = ILCreateFromPathW(filePath);
|
||||
SHOpenFolderAndSelectItems(pidl, 0, IntPtr.Zero, 0);
|
||||
ILFree(pidl);
|
||||
|
||||
try
|
||||
{
|
||||
SHOpenFolderAndSelectItems(pidl, 0, IntPtr.Zero, 0);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ILFree(pidl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue