title: Upload Custom Thumbnail to Sharepoint Image library
body: <p>I've got a webpart to upload images to a SharePoint image library, and SP does the thumbnail generation automagically.</p>
  
  <p>I'd like to give my users the options of uploading their own thumbnails, without SP doing it for them.</p>
  
  <p>Any thoughts how to do this?</p>
  
  <p>I do know that SP will store the thumbnails in a folder /_t in the library, but I can't seem to write files there programatically... 
  This is what I'm tring to do:</p>
  
  <pre><code> using (SPSite objSite = new SPSite("http://foo.com/"))
          {
              using (SPWeb objWeb = objSite.OpenWeb())
              {
                  //Need to abstract this library definition...
                  SPFolder mylibrary = objWeb.Folders["Media/_t"];
                  // Set AllowUnsafeUpdates = true to avoid security error
                  objWeb.AllowUnsafeUpdates = true;
                  mylibrary.Files.Add(System.IO.Path.GetFileName(filename), bytes);
              }
          }
  </code></pre>
  
  <p>If I do that I get an error message saying that value does not fall within expected range.</p>
  
  <p>Any ideas?</p>