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 7065885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:00:42+00:00 2026-05-28T05:00:42+00:00

Hello, thanks for reading my question. I have a string that I need to

  • 0

Hello, thanks for reading my question. I have a string that I need to put on a txt file.

I want to make it so that when the user clicks a button it asks for the folder, where the user wants to save this txt file, and generate it on in folder.

Here is some code I made but I do not know how to make it so that the user to chooses the folder.

private void Generar_Txt_Disco(string s_content, string s_folder)
{
        //Ruta es donde se va a guardar
        StreamWriter sr = new StreamWriter(s_folder);
        //Vas escribiendo el texto
        sr.WriteLine(s_content);
        //Lo cierras        
        sr.Close();           
}
  • 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-05-28T05:00:43+00:00Added an answer on May 28, 2026 at 5:00 am

    Description

    Use the SaveFileDialog or FolderBrowserDialog for that. (Member of System.Windows.Forms)

    SaveFileDialog Prompts the user to select a location for saving a file. This class cannot be inherited.

    FolderBrowserDialog Prompts the user to select a folder. This class cannot be inherited.

    Sample for FolderBrowserDialog

    private static void Generar_Txt_Disco(string s_content)
    {
        using (FolderBrowserDialog dialog = new FolderBrowserDialog()) 
        {
            if (dialog.ShowDialog()) == DialogResult.OK)
            {
               //Ruta es donde se va a guardar
                StreamWriter sr = new StreamWriter(dialog.SelectedPath + "\\YourFileName.txt");
                //Vas escribiendo el texto
                sr.WriteLine(s_content);
                //Lo cierras        
                sr.Close();
            }
        }
    }
    

    Sample for SaveFileDialog

    private static void Generar_Txt_Disco(string s_content)
    {
        using (SaveFileDialog dialog = new SaveFileDialog()) 
        {
            dialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    
            if (dialog.ShowDialog()) == DialogResult.OK)
            {
                //Ruta es donde se va a guardar
                StreamWriter sr = new StreamWriter(dialog.FileName);
                //Vas escribiendo el texto
                sr.WriteLine(s_content);
                //Lo cierras        
                sr.Close();
            }
        }
    }
    

    More Information

    • MSDN: SaveFileDialog Class
    • MSDN: FolderBrowserDialog Class
    • MSDN: How to: Save Files Using the SaveFileDialog Component
    • C# SaveFileDialog Tutorial
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello and thanks to everyone for reading my question. I've been working on a
Hello every one I want to ask a question about file transfer using sockets.
Hello all and thanks for your time reading this. I need to verify certificates
Hello everyone and thanks for reading. For means of QA, I want to setup
Thanks for reading! var data = <html><head><title>Hello</title></head><body>Hello Body</body></html>; I want to print data including
I have this kinda template text : Hello {#Name#}, Thanks for coming blah on
Hello everyone and thanks for reading... I'm a Mono / Web developer and was
Hello i have this XML and i want to sort all the MESSAGE/DATA/TRANSACTIONS/TRANSACTION With
Hello and thanks for reading. I am presently faced with the challenge of converting
I've been doing some reading into designing template code have a question about 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.