2009-10-14 9 views
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) 
        { 

        } 
       } 

Répondre

1

Vous ne pouvez pas faire ce

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

parce qu'un PDF est pas un format d'image et n'est pas comprise par .NET.

Voici une thread sur la façon de convertir le fichier PDF à une image en utilisant une bibliothèque 3ème partie

+0

Est-il possible à l'utilisateur AcroPDFLib pour résoudre ce scénario. – rockrule

+0

Je ne sais pas, je n'ai jamais utilisé AcroPDFLib avant. Essaie :) –

Questions connexes