HTML File Manipulation

4 posts, 1 answers
  1. sadiqabbas
    sadiqabbas avatar
    21 posts
    Member since:
    Mar 2009

    Posted 03 Mar 2009 Link to this post

    Hello Admin,

    Well I am a newbie so it might possible that I might be unable to search what i needed..

    Actually I needed a feature or want help in revealing feature. with RAD Edit

    I want to read external html file in rad edit and want to save data in same file when a button click event fired....

    sorry for poor english

    code below i tried
    using System.Text; 
    using System.IO; 
     
     
    public partial class wm_editor : System.Web.UI.Page 
         
        string qs = ""
        string filepath = ""
        protected void Page_Load(object sender, EventArgs e) 
        { 
            qs = Request.QueryString["e"]; 
            if (qs == "cdtls"
            { 
                string add = "contactus.htm"
                filepath = Server.MapPath(add); 
                RadEditor1.Content = ReadFile(filepath); 
                // edit contact details 
            } 
        } 
    public string ReadFile(string path) 
        { 
            if (System.IO.File.Exists(path)) 
            { 
                System.IO.StreamReader sr = new System.IO.StreamReader(path); 
                return sr.ReadToEnd(); 
            } 
            else 
            { 
                return string.Empty; 
            } 
        } 
    protected void btnupd_Click(object sender, EventArgs e) 
        { 
            System.IO.StreamWriter externalfile = new System.IO.StreamWriter(filepath, false, Encoding.UTF8); 
            externalfile.Write(RadEditor1.Content);       
        } 

    but does not getting any result

    Please Help me out
  2. Rumen
    Admin
    Rumen avatar
    14389 posts

    Posted 05 Mar 2009 Link to this post

    Hi Sadiqabbas,

    There is an online example that demonstrates the desired functionality. You can check it online here: Save In External File. More information is available here.

    Kind regards,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. sadiqabbas
    sadiqabbas avatar
    21 posts
    Member since:
    Mar 2009

    Posted 05 Mar 2009 Link to this post

    dear admin i m sorry to tell that i have done same i mean after referring that both example and help file i have written coding

    please reffer code i dont think there might be any problem with coding and still i corrected from old one with below new one

    // read file code which works well 
    public string ReadFile() 
        { 
            FileStream fs = new FileStream(Server.MapPath(filepath), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); 
            StreamReader sr = new StreamReader(fs, Encoding.UTF8); 
            string s = sr.ReadToEnd(); 
            sr.Close(); 
            return s; 
        } 
     
    // write or update file code (not working) 
    protected void btnupd_Click(object sender, EventArgs e) 
        { 
            FileStream fs = new FileStream(Server.MapPath(filepath), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); 
            StreamWriter wr = new StreamWriter(fs, Encoding.UTF8); 
            wr.Write(RadEditor1.Content); 
            wr.Close(); 
        } 
     
    // from example, i pasted direct code but there is no effect appeared
    protected void btnupd_Click(object sender, EventArgs e) 
        { 
            using (StreamWriter externalFile = new StreamWriter(this.MapPath(filepath), false)) 
            { 
                externalFile.Write(RadEditor1.Content); 
            } 
        } 


    but there is no effect of write file read file works well.. please if any other problem then please help me that what could be problem please help
  4. Answer
    Rumen
    Admin
    Rumen avatar
    14389 posts

    Posted 09 Mar 2009 Link to this post

    Hi,

    You should check whether you have set ASPNET / NETWORK SERVICE write permissions to the html file. If this does not help, please open a support ticket and send a fully working sample project that demonstrates the problem. I will examine it and provide a solution once I recreate the problem on my side.

    Greetings,
    Rumen
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top