This is a migrated thread and some comments may be shown as answers.

Derefrencing the carousel itemsource

3 Answers 50 Views
Carousel
This is a migrated thread and some comments may be shown as answers.
Suhas
Top achievements
Rank 2
Suhas asked on 24 Jul 2012, 03:44 PM
I have folder full of pngs. I add all the pngs to the the carousel and then after viewing those in Carousel, I need to delete those from my hard disk. But it gives me an error saying the files are still used by the carousel. How do delete the image source??

3 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 24 Jul 2012, 03:53 PM
Hello Suhas,

You can clear the source of the carousel and remove the images after that.  

Kind regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Suhas
Top achievements
Rank 2
answered on 24 Jul 2012, 04:45 PM
MyCarousel.BeginInit();
            foreach (string png in Directory.GetFiles(output))
            {
                Image myimage = new Image();
                var uri = new Uri(png);
                myimage.Source = new BitmapImage(uri);
                myimage.Height = 200;
                myimage.Width = 200;
                myImages.Add(myimage);
                
            }          
            MyCarousel.ItemsSource = myImages;
            MyCarousel.EndInit();

To release the files used in carousel, I am doing following

MyCarousel.ItemSource = null;
MyCarousel.Items.Clear();
GC.Collect();

but still when I delete the pngs in a output folder, I get an exception saying pngs are being used by another process 
which is this RadCarousel. 
0
Maya
Telerik team
answered on 25 Jul 2012, 07:52 AM
Hello Suhas,

Could you take a look at this forum thread and follow the ideas illustrated in the threads mentioned there ? Do you still get the same exception ? 

All the best,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Carousel
Asked by
Suhas
Top achievements
Rank 2
Answers by
Maya
Telerik team
Suhas
Top achievements
Rank 2
Share this question
or