This is a migrated thread and some comments may be shown as answers.

HTML File Manipulation

3 Answers 63 Views
Editor
This is a migrated thread and some comments may be shown as answers.
sadiqabbas
Top achievements
Rank 1
sadiqabbas asked on 03 Mar 2009, 12:48 PM
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

3 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Mar 2009, 04:12 PM
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.
0
sadiqabbas
Top achievements
Rank 1
answered on 06 Mar 2009, 05:26 AM
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
0
Accepted
Rumen
Telerik team
answered on 09 Mar 2009, 12:52 PM
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.
Tags
Editor
Asked by
sadiqabbas
Top achievements
Rank 1
Answers by
Rumen
Telerik team
sadiqabbas
Top achievements
Rank 1
Share this question
or