Introduction
In this article, I am going to explain how to use a SaveFileDialog in a Windows.Forms app using Visual Studio 2017.
SaveFileDialog
The SaveFileDialog prompts the users while saving files. This control allows the user to set a file name for a file. Then, you can use the event handling mechanism to add a custom code. This writes the file that the user wants to save.
STEP 1 - Create a new project
Let's create a new project using Visual Studio 2017.
Select New Project->Visual C#->Windows Forms App (.NET Framework), give your project a name and click OK.
Let's create a new project using Visual Studio 2017.
Select New Project->Visual C#->Windows Forms App (.NET Framework), give your project a name and click OK.
This action creates a WinForms project with a default form and you should see the Windows Designer.
STEP 2 - Drag and Drop Controls
Let's add a SaveFileDialog control to the form by dragging it from the Toolbox and dropping it to the form. You will see that a SaveFileDialog is added to the form. This control is now available for you in the code behind.
STEP 2 - Drag and Drop Controls
Let's add a SaveFileDialog control to the form by dragging it from the Toolbox and dropping it to the form. You will see that a SaveFileDialog is added to the form. This control is now available for you in the code behind.
Additional controls
Now, let's add other controls, like Font Dialog, Color Dialog, Label, Button control to the form by dragging these from the toolbox. You may also want to change the properties of the other controls.
The Button control is used to open the SaveFileDialog. Like any Dialog, you must call the ShowDialog method to open your saveFileDialog. To add a click event handler to the saveFileDialog, double click on the button in the designer.
Font and Color Dialog controls are used to change the font and color of the content displayed in the form.
STEP 3 - Coding for Button Click Event
You can add a button-click event handler by simply double-clicking on the button control event handler. We can save the file using saveFileDialog after changing the color and font using color and font Dialog control.
You can add a button-click event handler by simply double-clicking on the button control event handler. We can save the file using saveFileDialog after changing the color and font using color and font Dialog control.


Menaka Priyadharshini BPosted Oct 10, 2018, 10:46 PM
Yes sure i will update sir
Menaka Priyadharshini BPosted Oct 10, 2018, 10:46 PM
Yes sure i will update sir
Rajanikant HawaldarPosted Oct 10, 2018, 9:26 PM
Remove unwanted braces, keep String font,String color declarations inside try block, call sw.Flush(); before sw.Close();