File location for radgrid export

2 posts, 0 answers
  1. Edd
    Edd avatar
    37 posts
    Member since:
    Jan 2013

    Posted 02 Jul 2014 Link to this post

    Dear all,

    I have a a radgrid in which i export into csv. The problem is I want to export into  a specified folder and not the default location.
    How can i achieve. Any help or advice. thanks
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Jul 2014 in reply to Edd Link to this post

    Hi Edd,

    Please try the below C# code snippet to achieve your scenario.

    C#:
    protected void RadGrid1_GridExporting(object source, GridExportingArgs e)
    {
        string path = Server.MapPath("~/NewFolder1/MyFile.xls");//specify the folder name
        using (FileStream fs = File.Create(path))
        {
            Byte[] info = System.Text.Encoding.Default.GetBytes(e.ExportOutput);
            fs.Write(info, 0, info.Length);
        }
        Response.Redirect(Request.Url.ToString());
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top