Silverlight File Dialog Save

Posted on

Silverlight File Dialog Save Average ratng: 8,3/10 5022reviews

Save. File. Dialog in Silverlight 3. Introduction Save. File. Dialog was a component that was missing in earlier versions of Silverlight. Thankfully now Silverlight 3 includes this component so that it becomes much easier to save files using this component. Save. File. Dialog To start with, let us create a new Silverlight 3 application using Visual Web Developer 2. The default code in Main. Page. xaml will be seen as follows lt User. Control x ClassSFDemo. Main. Page    xmlnshttp schemas. Ignorabled d Design. Width6. 40 d Design. Height4. 80  lt Grid x NameLayout. Html Save File DialogRoot  lt Grid lt User. Control Replace the lt Grid lt Grid tags with lt Canvas lt Canvas. Drag and drop Text. Box and Button controls from the Toolbox. Configure their properties as shown below lt User. Control x ClassSFDemo. Main. Page    xmlnshttp schemas. Ignorabled d Design. Width6. 40 d Design. Height4. 80  lt Canvas x NameLayout. Root lt Text. Box Nametxt. Contents Accepts. ReturnTrue Canvas. Left4. 0 Canvas. Top1. Width1. Save As Dialogsave file dialog in silverlight 4. Hello community i am using silverlight 4. Saving Files Locally in Silverlight. The second part is displaying the dialog that allows you to save a file. Create a new Silverlight application. Save Dialog box in Silverlight. PC. when we click on Export Button save file dialog box appear and save at selected location. Height8. 0 lt Text. Box      lt Button Namebtn. Ok ClickButtonClick Canvas. Left4. 0 Canvas. Top1. ContentOK lt Button  lt Canvas lt User. Lord Of The Rings The Third Age Pc Crack Game more. OpenAndSave/serialized.png' alt='Silverlight File Dialog Save' title='Silverlight File Dialog Save' />Control This will render the UI with a text box and a button with caption Ok. The event handler ButtonClick will be auto generated as a result of the above code. Within this event handler, we will now add code to use the Save. File. Dialog component. First, however, you need to add using statements for two namespaces System. Text and System. IO. System. IO using System. Text Next, in the event handler for the button, add the following code privatevoid ButtonClickobject sender, Routed. Event. Args e            Save. File. Dialog sd new. Save. File. Dialog            sd. C# Wpf Save File Dialog' title='C# Wpf Save File Dialog' />The SaveFileDialog will help you select a location and a filename when you wish to save a file. It works and looks much like the OpenFileDialog which we used in the. Default. Ext. Filter Text Files. Log Files logAll Files            bool Result sd. Show. Dialog            if dialog. UploadFile/2b876a/migrate-silverlight-phone-8-1-apps-to-windows-10/Images/tool.png' alt='Vb Save File Dialog Example' title='Vb Save File Dialog Example' />Result true                            byte contents                System. Text. Encoding ascii Encoding. Unicode                contents ascii. Get. Bytestxt. Contents. Text                using Stream fs Streamsd. Open. File                                    fs. Writecontents, 0, contents. Length                    fs. Close                    Message. Box. ShowFile successfully saved                            What has been done here is that an instance of Save. File. Dialog is created. Properties of this instance, sd, are then configured. Default. Ext is the property for default extension of the file to be saved. Filter allows you to filter the file extensions and types. Then the dialog is opened through the Show. Dialog method. The return value is stored in a boolean variable, dialog. Result. This dialog. Result is then checked to see if it is true. If true,  the contents of the text box are retrieved, converted to byte array and then written into the file which was chosen in the Save. File. Dialog dialog window. A message box notifies the user of the successful save operation. When you run the application, enter some text in the text box and then click OK. This will open the Save file dialog. Provide a file name in the Save file dialog. After the message box is displayed, close the browser window and test whether the file saved contains the text from the text box. Conclusion This article demonstrated how to use the Save. File. Dialog component.