I was trying to upload images to a Pictures Library, and getting thumbnailing working, and so on. I found that thumbnailing wasn’t working, so I kept trying to create and upload my own thumbnail, which was pretty dumb. SharePoint will do that for you – but you’ve got to upload your file with a correct extension for an image format…
The code that worked was:
SPPictureLibrary pics = (SPPictureLibrary)site.Lists["Pictures"];
FileStream fs = new FileStream(@"c:lolrus.jpg",FileMode.Open,FileAccess.Read);
Previously I’d been trying this for the final line:
The thumbnails weren’t being generated because I failed to have the .jpg extension. I guess I figured I was defining the Display Name of the item, rather than the file name. I added in the ‘.jpg’ and when I uploaded my image, thumbnails were automatically generated. Nice.