my .aspx code is as follows.
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"><title>Untitled Page</title><style type="text/css"> .style1 { width: 100%; }</style></head><body><form id="form1" runat="server"><div><table class="style1"><tr><td><asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager></td></tr><tr><td><asp:TextBox ID="txt_TeamName" runat="server"></asp:TextBox></td></tr><tr><td><asp:TextBox ID="txt_ModuleName" runat="server"></asp:TextBox></td></tr><tr><td><asp:FileUpload ID="FileUpload1" runat="server" /></td></tr><tr><td><asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" /> <asp:Button ID="btn_view" runat="server" Text="View" /></td></tr><tr><td><asp:Panel ID="Panel1" runat="server"><asp:ImageButton ID="ImageButton1" runat="server" /><asp:Image ID="Image1" runat="server" /><asp:ImageButton ID="ImageButton2" runat="server" /><br /><b>Name:</b><asp:Label ID="lblImageTitle" runat="server" Text="Label" /><br /><b>Description:</b><asp:Label ID="lblImageDescription" runat="server" Text="Label" /></asp:Panel> </td></tr></table><asp:SlideShowExtender ID="SlideShowExtender1" ImageTitleLabelID="lblImageTitle" ImageDescriptionLabelID="lblImageDescription" SlideShowServiceMethod="GetImages" AutoPlay="true" PlayInterval="10000" PreviousButtonID="ImageButton1" TargetControlID="Image1" NextButtonID="ImageButton2" Loop="true" runat="server" > </asp:SlideShowExtender><asp:ModalPopupExtender ID="ModalPopupExtender1" TargetControlID="btn_view" CancelControlID="Button1" PopupControlID="Panel1" runat="server"></asp:ModalPopupExtender> </div></form></body></html>
my .cs code is as follws...
using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.SqlClient; using System.IO; using Microsoft.Office.Core; using Microsoft.Office.Interop; using AjaxControlToolkit; using System.Web.Services; using System.Web.Script.Services; using System.Collections.Generic; public partial class HomePage : System.Web.UI.Page { public SqlConnection con = new SqlConnection("Data Source=10.91.82.195;Initial Catalog=OPPRDashbaord;Integrated Security=True"); public static string Filepath; public static string ImageFilePath; public string vFilePath; public string vImagePath; public static string vFileName; public string vModule; public string vTeamName; public string vUser; public static string vImagefromDB; public static string vPath; public static DataTable vDT=new DataTable(); protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } Filepath = @"C:\Documents and Settings\ade121\My Documents\Visual Studio 2008\WebSites\OPPR_Board\PPT"; ImageFilePath = @"C:\Documents and Settings\ade121\My Documents\Visual Studio 2008\WebSites\OPPR_Board\Images"; } protected void Button1_Click(object sender, EventArgs e) { if (txt_TeamName.Text == "" || txt_TeamName.Text == null) { } else { CreateFolder(); } } public void CreateFolder() { vTeamName = txt_TeamName.Text.TrimEnd().ToString(); // Getting a Team Name vModule = txt_ModuleName.Text.TrimEnd().ToString(); // Getting A module name vFileName = FileUpload1.FileName; // File Name vFilePath = Filepath + "\\" + vTeamName + "\\"; // file path vImagePath = ImageFilePath + "\\" + vTeamName+"\\"; // image Path /* File Directory */ if (System.IO.Directory.Exists(vFilePath)) { if (System.IO.Directory.Exists(Path.Combine(vFilePath + "\\", vModule))) { } else { System.IO.Directory.CreateDirectory(Path.Combine(Filepath + "\\" + vTeamName, vModule)); // creating folder for module in team folder } } else { System.IO.Directory.CreateDirectory(Path.Combine(Filepath, vTeamName)); // creating Folder for Team System.IO.Directory.CreateDirectory(Path.Combine(vFilePath, vModule)); // creating folder for module in team folder } // vFilePath = vFilePath +"\\"+ vModule; FileUpload1.SaveAs(Path.Combine(vFilePath,vModule)+"\\"+vFileName); // Saving File /* Image Directory */ if (System.IO.Directory.Exists(vImagePath)) { if (System.IO.Directory.Exists(Path.Combine(vImagePath + "\\", vModule))) { DirectoryInfo vDir = new DirectoryInfo(vImagePath + "\\" + vModule); // vDir.Delete(true); foreach (FileInfo vFi in vDir.GetFiles()) { vFi.Delete(); } } else { System.IO.Directory.CreateDirectory(Path.Combine(vImagePath, vModule)); // creating folder for module in team folder } } else { System.IO.Directory.CreateDirectory(Path.Combine(ImageFilePath, vTeamName)); // creating Folder for Team System.IO.Directory.CreateDirectory(Path.Combine(vImagePath, vModule)); // creating folder for module in team folder } ConvertPPT_To_Images(Path.Combine(Path.Combine(vFilePath,vModule),vFileName),Path.Combine(vImagePath,vModule)+"\\"); } private void ConvertPPT_To_Images(string sPPTFilePath, string sImagesDirectoryPath) { try { Microsoft.Office.Interop.PowerPoint.Application appPpt = new Microsoft.Office.Interop.PowerPoint.Application(); Microsoft.Office.Interop.PowerPoint.Presentation objActivePresentation = appPpt.Presentations.Open(sPPTFilePath, Microsoft.Office.Core.MsoTriState.msoCTrue, Microsoft.Office.Core.MsoTriState.msoTriStateMixed, Microsoft.Office.Core.MsoTriState.msoFalse); //objActivePresentation.SaveAs(sImagesDirectoryPath, PpSaveAsFileType.ppSaveAsJPG, MsoTriState.msoFalse); //objActivePresentation.Export(sImagesDirectoryPath + @"\Slide1.png", "png", 960, 720); //objActivePresentation.SaveAs(sImagesDirectoryPath + "slide", PpSaveAsFileType.ppSaveAsTIF, MsoTriState.msoFalse); int i = 0; foreach (Microsoft.Office.Interop.PowerPoint.Slide objSlide in objActivePresentation.Slides) { //Names are generated based on timestamp. //objSlide.Export("Slide" + i, "PNG", 960, 720); //objSlide.Export(sImagesDirectoryPath + "Slide" + i + ".PNG", "PNG", 900, 600); objSlide.Export(sImagesDirectoryPath + "" + vTeamName.ToUpper().ToString() + "" + "-" + "" + vModule.ToUpper().ToString() + "" + "-" + i + ".PNG", "PNG", 900, 600); i++; } objActivePresentation.Close(); appPpt.Quit(); } catch (Exception ex) { throw; } } [WebMethod] [ScriptMethod] public static Slide[] GetImages() { List<Slide> slides = new List<Slide>(); string path = HttpContext.Current.Server.MapPath("~/images/"); Uri pathUri = new Uri(path, UriKind.RelativeOrAbsolute); string[] files = Directory.GetFiles(path); foreach (string file in files) { Uri filePathUri = new Uri(file, UriKind.RelativeOrAbsolute); slides.Add(new Slide { Name = Path.GetFileNameWithoutExtension(file), Description = Path.GetFileNameWithoutExtension(file) + " Description.", ImagePath = pathUri.MakeRelativeUri(filePathUri).ToString() }); } return slides.ToArray(); } }
i am saving path of image folder in database.
i want to pass Dynamic path from database to GetImages.
How to do i ???
i hv tried a lot but somehow its not working...
plz reply as early as possible.
waiting for replies..