views:

651

answers:

1
ImageList imageList = new ImageList();
                if (folder != null && System.IO.Directory.Exists(folder))
                {
                    try
                    {
                        string[] arrImageName=new string[1000];
                        int Count = 0;
                        string CutName;
                        DirectoryInfo dir = new DirectoryInfo(@folder);
                        foreach (FileInfo file in dir.GetFiles())
                        {
                            try
                            {

                                imageList.ImageSize = new Size(140, 140);
                                imageList.ColorDepth = ColorDepth.Depth32Bit;
                                Image img1 = Image.FromFile(file.FullName);
                                CutName = file.FullName;
                                CutName = CutName.Replace(folder, "");
                                CutName = CutName.Replace("\\", "");
                                arrImageName[Count] = CutName;
                                imageList.Images.Add(FormatImage(imageList.ImageSize.Width, img1));                              
                                Count = Count + 1;
                            }
                            catch
                            {
                                Console.WriteLine("This is not an image file");
                            }     
                        }


                        for (int j = 0; j < imageList.Images.Count; j++)
                        {
                            this.ListView1.Items.Add((j + 1) + "/" + imageList.Images.Count + " " + "\r\n" + arrImageName[j]);                                
                            this.ListView1.Items[j].ImageIndex = j;
                        }

                        this.ListView1.View = View.LargeIcon;
                        this.ListView1.LargeImageList = imageList;
                        //import(folder);
                    }
                    catch (Exception ex)
                    {

                    }
                }
+1  A: 

You cant do this

 Image img1 = Image.FromFile(file.FullName);

because a PDF is not an image format and is not understood by .NET.

Here is a thread on how to convert the PDF to an image using a 3rd party library

Andrew Keith
Is there a possibility to user AcroPDFLib to solve this scenario.
rockrule
i dont know, I have never used AcroPDFLib before. Give it a try :)
Andrew Keith