0

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?

Code Pope
  • 5,075
  • 8
  • 26
  • 68
  • 2
    https://stackoverflow.com/questions/12654835/accessing-thumbnails-that-dont-exist - Trust me this is your problem, it will help you – EpicKip Jul 03 '17 at 10:05
  • Can you try accessing the Image after a delay of Saving the file? Add Thread.Sleep(2000); after the Save(). ? – Habeeb Jul 03 '17 at 10:16
  • @EpicKip I have tried the code and all flags. It does not work and I have tried all flags. – Code Pope Jul 03 '17 at 12:03
  • @Habeeb Yes I have tried also minutes of waiting, but it does not work. It works after I click on the file for the first time. – Code Pope Jul 03 '17 at 12:07

0 Answers0