Re: how i get all categories name with folder path

  •  10-21-2010, 9:15 PM

    Re: how i get all categories name with folder path

    hi raneamey,
     
    Please try the example below. It shows you how to get the physical path and virtual path of the categories.
     
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register TagPrefix="DotNetGallery" Namespace="DotNetGallery" Assembly="DotNetGallery" %>  
    4.   
    5. <script runat="server">  
    6.     void Page_Load(object sender, EventArgs e)  
    7.     {  
    8.         using (DotNetGallery.GalleryDataProvider provider = DotNetGallery.GalleryDataProvider.CreateInstance(Context, "~/GalleryFiles/"))  
    9.         {  
    10.             //get all category  
    11.             string[] categoryArray = provider.GetCategoryArray();  
    12.             for (int i = 0; i < categoryArray.Length; i++)  
    13.             {  
    14.                 string title;  
    15.                 string description;  
    16.                 string properties;  
    17.                 string physicalPath = provider.PhysicalDirectory;  
    18.                 string virtualPath = provider.VirtualDirectory;  
    19.             
    20.                 if (provider.GetCategoryInfo(categoryArray[i].ToString(), out title, out description, out properties))  
    21.                 {  
    22.                     //show all title in label1  
    23.                     //title is the name of the category  
    24.                     string s = "Category " + i.ToString() + " physical path: " + physicalPath + title+"<br/>";  
    25.                     label1.Text += s;  
    26.                     string s2 = "Category " + i.ToString() + " virtual path: " + virtualPath + title + "<br/>";  
    27.                     label1.Text += s2;  
    28.                 }  
    29.             }  
    30.         }  
    31.     }  
    32.    
    33. </script>  
    34.   
    35. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">  
    36. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
    37. <head id="Head1" runat="server">  
    38.     <title></title>  
    39. </head>  
    40. <body>  
    41.     <form id="form1" runat="server">  
    42.         <asp:Label ID="label1" runat="server"></asp:Label>  
    43.         <DotNetGallery:GalleryBrowser runat="server" ID="gallery1" Width="720" Height="430" />  
    44.     </form>  
    45. </body>  
    46. </html> 
     Regards,
     
    ken
View Complete Thread