Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8954059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:13:54+00:00 2026-06-15T14:13:54+00:00

I want to save a file using the SaveFileDialog control. Why does the file

  • 0

I want to save a file using the SaveFileDialog control. Why does the file need to already exist in order to save it?

This is the code I am using:

string month = dateTimePicker1.Value.Month.ToString();
string year = dateTimePicker1.Value.Year.ToString();
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.InitialDirectory = @"C:\";
saveFileDialog1.Title = "Save Sql Files";
saveFileDialog1.FileName = "MysqlBackup-"+month+"-"+year+".sql";
saveFileDialog1.CheckFileExists = true;
saveFileDialog1.DefaultExt = "Sql";
saveFileDialog1.Filter = "Sql files (*.Sql)|*.Sql";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
    {
    // Here is the error. After typing in the filename, when I click OK it gives me an error stating that the file does not exist.
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:13:56+00:00Added an answer on June 15, 2026 at 2:13 pm

    This line requires that the file exists in the selected folder

    saveFileDialog1.CheckFileExists = true;
    

    set it to false and you could exit with OK if the file doesn’t exist

    CheckFileExists on MSDN

    Gets or sets a value indicating whether the dialog box displays a
    warning if the user specifies a file name that does not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Excel 2010. I'm trying so save my excel file, with this code.
I want to map w! in vim to save a file using sudo silently
I want to download and save pdf file to internal storage. Here is code
I want to save gtk.DrawingArea() object contents to jpeg file using PIL. Particularly I
I am trying to save a file using GetSaveFileName and want to have a
I'm using MVC.I want to save xml file inside the services class. so wrote
I want to save a file when my application ends. For that, I need
I want to save an XML file using XML serialization on the server and
I save a png file using savedialogfile. But I want to save it in
i am generating an xml file using XDocument. when i save this file it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.