VS C# 2008 File Dialog

Posted on 2011-10-20
Last Modified: 2012-05-12
I am trying to present to the user a textbox that will contain a filename, complete with path, that is derived by providing a lookup to where you want this file to go. The textbox is called txtFileName.

I am trying to follow the example in the code provided below but even though I have included the System.Windows.Forms namespace it does not recognize saveFileDialog1 all I get is saveFileDialog and there is no Filter directive. What am I mssing?
private void btnSave_Click(object sender, EventArgs e)
             saveFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
             saveFileDialog1.FilterIndex = 1;
             if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                 StreamWriter myStream = new StreamWriter(saveFileDialog1.FileName, true);

Open in new window

Question by:rwheeler23
    LVL 74

    Accepted Solution

    SaveFileDialog is a class, and you have to create an instance of it in order to work with it in the manner that you have displayed. For forms, you typically "create" an instance by dragging it onto the form from the "Components" section of the ToolBox.

    Are you working with an instance of SaveFileDialog?

    Author Comment

    I see what you mean. I am learning as quickly as I can. Thanks for the tip I have it working now.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now