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

setting the table width

3 Answers 91 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Angeli
Top achievements
Rank 1
Angeli asked on 30 May 2011, 03:01 AM
hi!


(sorry the title doesn't match my question. i posted a question a while ago, but it was already solved so i just updated it with another question)

how can i save a file automatically to a directory. i have a code that saves a file but it uses a save file dialog. how can i save it without showing the savefile dialog?

//here's my code that uses a save file dialog

SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = "*.html";
dialog.Filter = "WORD Document (*.html)|*.html";

if (dialog.ShowDialog() == true)
{
    RadDocument document = CreateDocument(rgvReportData);

    document.LayoutMode = DocumentLayoutMode.Paged;

    document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
    document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
    document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(2, 2, 2, 2);
    document.SectionDefaultPageOrientation = PageOrientation.Landscape;
    
    HtmlFormatProvider provider = new HtmlFormatProvider();

    using (Stream output = dialog.OpenFile())
    {
        provider.Export(document, output);
    }
}

3 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 01 Jun 2011, 05:04 PM
Hello Angeli,

You cannot save files on the client in any other way than the SaveFileDialog due to Silverlight's security policy. If you want to save the file on the server, you can either export the content of the document to a stream in the Silverlight application and use a WebClient to pass the stream to the server or use the WPF assemblies in the ASP project and export the document there. There is a demo with RadRichTextBox and WCF services, which you mind find helpful, in this forum thread.

Greetings,
Iva
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
Raventhorn
Top achievements
Rank 2
answered on 07 Jun 2012, 02:28 AM
Sorry to open this back up but is there no way to keep the savefile dialog's stream open and continue to write to it? For example, if I want to implement autosave to a file on the desk after they already selected to manually save once is this possible?
0
Iva Toteva
Telerik team
answered on 08 Jun 2012, 12:59 PM
Hi Shannon,

It is not possible to cheat Silverlight in this way. The framework does not allow communication with files on the client without user interaction by design. In addition, opening and saving files is restricted to using the Open and SaveFileDialog and accessing their streams after the dialog has been closed is not possible.

Greetings,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
Angeli
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Raventhorn
Top achievements
Rank 2
Share this question
or