Hello all, I've got a really weird issue. I'm trying to upload a set of image files programmatically and I'm was running into a problem where CreateImage() was creating Image objects with the same Guid each time called, even with calling .SaveChanges() in between. I resorted to making a new Guid manually and calling CreateImage() with the new Guid. That problem was solved. Now, when I upload an image, regardless of what file I send, it uploads the same image. This is my code:
public Guid ImportImage(String fileName, String title)
var im = lm.CreateImage(Guid.NewGuid());
im.Title = title;
im.Parent = lm.GetAlbums().FirstOrDefault();
lm.Upload(im, File.Open(baseDirectoryURL + fileName, FileMode.Open, FileAccess.Read), ".jpg");
This method is called multiple times in a for loop, each time with a different filename. Ex.
foreach (String f in filenames)
But it only seems to upload whatever the first file is each time. Furthermore, the thumbnail is also completely different from the file. Can anyone help?? Thanks
LibrariesManager librariesManager = LibrariesManager.GetManager();
Telerik.Sitefinity.Libraries.Model.Image image = librariesManager.CreateImage(Guid.NewGuid());
Album album = librariesManager.GetAlbums().SingleOrDefault(x => x.UrlName ==
image.Parent = album;
image.DateCreated = DateTime.UtcNow;
image.PublicationDate = DateTime.UtcNow;
image.LastModified = DateTime.UtcNow;
image.UrlName = Regex.Replace(image.Title.ToLower(), @
//Recompiles and validates the url of the Image.
FileStream fileStream =
extension = Path.GetExtension(imagePath);
//Upload the Image
librariesManager.Upload(image, fileStream, extension);
//Save the changes.
//Publish the Image item. The live version acquires new ID.
var bag =