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

Save File without Dialog Box

2 Answers 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Vincent asked on 31 May 2011, 06:14 AM
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 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 31 May 2011, 01:44 PM
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
0
Vincent
Top achievements
Rank 1
answered on 01 Jun 2011, 02:58 AM
Thanks Iva! I got it now!!!!!!!!!! :)
Tags
General Discussions
Asked by
Vincent
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Vincent
Top achievements
Rank 1
Share this question
or