Save File without Dialog Box

3 posts, 0 answers
  1. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 31 May 2011 Link to this post

    Hi!! I have a code here saving images in the local drive without using savefiledialogbox. My problem here is I want to save RadGridView into html file without using savefiledialogbox. Is it possible?
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1216 posts

    Posted 31 May 2011 Link to this post

    Hi Vincent,

    Please, refer to the illustrated approach:
    string fileName = "C:\\Users\\iivanov\\Documents\\test.xls";
                byte[] binary;   
      
                MemoryStream ms = new MemoryStream();
                clubsGrid.Export(ms,
                         new GridViewExportOptions()
                         {
                             Format = ExportFormat.Html,
                             ShowColumnHeaders = true,
                             ShowColumnFooters = true,
                             ShowGroupFooters = false,
                         });
           
                BinaryWriter bwriter = new BinaryWriter(ms); 
                bwriter.Write(true); 
                binary = ms.ToArray(); 
                bwriter.Close(); 
                ms.Close();
                            
                using (dynamic adoCom = AutomationFactory.CreateObject("ADODB.Stream"))
                {
                    adoCom.Type = 1;
                    adoCom.Open();
                    adoCom.Write(binary);
                    adoCom.SaveToFile(fileName, 2);
                }

    Pay attention that the application is not given full control over the whole local file system, but to several folders like "MyDocuments", "MyPictures" etc.

    Greetings,
    Ivan Ivanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Vincent
    Vincent avatar
    34 posts
    Member since:
    Apr 2011

    Posted 31 May 2011 Link to this post

    Thanks Iva! I got it now!!!!!!!!!! :)
Back to Top