I have a file which I have to copy to another directory and after that I want to get the thumbnail of the file that is shown in Windows Explorer.
I am using the following lines of code to get the thumbnail:
shellFile.Thumbnail.FormatOption = ShellThumbnailFormatOption.ThumbnailOnly;
Bitmap shellThumb = shellFile.Thumbnail.ExtraLargeBitmap;
shellThumb.Save("E:\\test.jpg",ImageFormat.Jpeg);
This works fine when used on a ready file. But if I copy a file from one directory to another one by File.Copy
and then I call immediately the mentioned shellFile
code lines, it will block and cannot create the thumbnail. And it is blocked until I go manually to the directory of the file in Windows Explorer and click on the file. After that the shellFile
code does work and I do get my thumbnail.
How can I get the thumbnail of a copied file without manually going to the file and clicking on it?