Count number of images

Last post 12-05-2010, 7:45 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  12-04-2010, 1:41 AM 65263

    Count number of images

    I want to count the number of images in a folder and display it in the label and then create a session of it and pass it to other page... reply as soon as possible
  •  12-05-2010, 7:45 PM 65282 in reply to 65263

    Re: Count number of images

    Hi amw123,
     
    Please test the example below, it will shows you how many images in each category.
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register TagPrefix="DotNetGallery" Namespace="DotNetGallery" Assembly="DotNetGallery" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.     protected override void OnLoad(EventArgs e)  
    8.     {  
    9.         using (DotNetGallery.GalleryDataProvider provider = DotNetGallery.GalleryDataProvider.CreateInstance(Context, "~/GalleryFiles/"))  
    10.         {  
    11.             //get all category  
    12.             string[] categoryArray = provider.GetCategoryArray();  
    13.   
    14.             for (int i = 0; i < categoryArray.Length; i++)  
    15.             {  
    16.                 string[] photoArray = provider.GetPhotoArray(categoryArray[i]);  
    17.                 label1.Text += "There is : " + photoArray.Length.ToString() + " images in category" + i.ToString() + "</br>";  
    18.             }  
    19.   
    20.         }  
    21.         base.OnLoad(e);  
    22.     }  
    23. </script>  
    24.   
    25. <html xmlns="http://www.w3.org/1999/xhtml">  
    26. <head runat="server">  
    27.     <title>Untitled Page</title>  
    28. </head>  
    29. <body>  
    30.     <form id="form1" runat="server">  
    31.         <asp:Label ID="label1" runat="server"></asp:Label>  
    32.         <DotNetGallery:GalleryBrowser ID="galleryBrowser1" runat="server" AllowEdit="true" />  
    33.     </form>  
    34. </body>  
    35. </html> 
    Regards,
     
    ken 
View as RSS news feed in XML