Hello-
Here is the code for the last line the RemovePhotos method:
I have created a UserControl with the RadRotator on it and 4 buttons. 1 for Previous, 1 for View, 1 for Remove, and 1 for Next. All the buttons work except the Remove button. Here is my code to add images to the RadRotator:
| foreach (FileInfo photoFileInfo in m_photos) |
| { |
| Bitmap photoBitmap = new Bitmap(Image.FromFile(photoFileInfo.FullName), 313, 253); |
| RadImageItem radImageItem = new RadImageItem |
| { |
| Image = photoBitmap, |
| Tag = photoFileInfo.Name |
| }; |
| this.InvokeIfNeeded(() => photoRadRotator.Items.Add(radImageItem)); |
| } |
The Remove button calls the RemovePhoto Method. Here is the event handler for the delete button:
| if (photoRadRotator.CurrentItem != null) |
| { |
| RadItem currentItem = photoRadRotator.CurrentItem; |
| string fileNameString = currentItem.Tag.ToString(); |
| foreach (RadItem radItem in photoRadRotator.Items) |
| { |
| List<RadItem> items = new List<RadItem>(); |
| if (radItem != currentItem) |
| items.Add(radItem); |
| ((RadImageItem) radItem).Image = null; |
| } |
| photoRadRotator.Items.Clear(); |
| currentItem.Dispose(); |
| this.RemovePhotos(fileNameString); |
| } |
| if (!Directory.Exists(m_unusedFolder)) |
| { |
| Directory.CreateDirectory(m_unusedFolder); |
| } |
| File.Move(Path.Combine(m_associatedFolder, fileToRemove), |
| Path.Combine(m_unusedFolder, fileToRemove)); |
I an error on the File.Move line that says the file is in use by another process. I have determined that the RadRotator i still holding on to the file through the Image property of the RadImageItem. I am trying to allow a user to look through a directory of photos using the RadRotator. If they find a photo they want to remove, they click the delete button and the photo is removed from the RadRotator and moved to another directory.
How can I programmatically remove an item from the RadRotator and then move it to another directory without the RadRotator still having a lock on the file?
Thanks,
Chance