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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:29:26+00:00 2026-05-24T05:29:26+00:00

If I set path = C:\\MSREAD.txt; and Click on SaveAs Menu Item ,it saves

  • 0

If I set path = "C:\\MSREAD.txt"; and Click on SaveAs Menu Item ,it saves Filetext,But If I dont give the String path and save it from saveFD.FileName it doesnt work.Please help me with this issue.
Thanks a lot

public void SaveToFile()
{
    String SavedFile = "";
    saveFD.InitialDirectory = @"C:";
    saveFD.Title = "Save a Text File";
    saveFD.FileName = "";
    RichTextBox richTextBox1 = new RichTextBox();

    saveFD.Filter = "Text Files|*.txt|All Files|*.*";
    try
    {
        if (saveFD.ShowDialog() != DialogResult.Cancel)
        {
            SavedFile = saveFD.FileName;
            path = SavedFile.ToString();
            //path = "C:\\MSREAD.txt";                   
            MessageBox.Show(path);
            richTextBox1.SaveFile(path, RichTextBoxStreamType.PlainText);
            SaveMyTextBoxContents(path);
        }
    }
    catch(Exception e)
    {
     MessageBox.Show(e.ToString());
    }
}

private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
    SaveToFile();
}

public void SaveMyTextBoxContents(string path)
{
    if (listBoxItems.SelectedIndex == -1)
    {
        if (rdBtnSlow.Checked && rdBtnNo.Checked)
        {
            using (StreamWriter outputFile = new StreamWriter(path))
            {
                foreach (string item in listBoxItems.Items)
                {
                    saveAllText = slowNo + " " + item;
                    outputFile.WriteLine(saveAllText);
                }
            }
        }
    }
}
  • 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-24T05:29:27+00:00Added an answer on May 24, 2026 at 5:29 am

    Here is your problem:

    richTextBox1.SaveFile(path, RichTextBoxStreamType.PlainText);
    SaveMyTextBoxContents(path);
    

    You first save the richTextBox text to file, but then override the same file with SaveMyTextBoxContents, However the file is empty because of SaveMyTextBoxContents method will only save something if some conditions are true “not selected item and both check boxes are checked”, and the listBoxItems.Items.Count > 0 which apparently not the case

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

Sidebar

Related Questions

I want to make sure a file path set via query string does not
How do I set a path for DLL files to be searched in Visual
Hi I want to set dynamic path to my picture box in winforms. Is
in my config.php where i have all constants i set the PATH to a
Is there a way to set the initial path for the FileUpload widget in
Where is the setting in Visual Studio 2003 to set the include path for
In my script, I set the include path (so another part of the application
For example, is it possible to set the Output path to your app folder
Getting Invalid Application Path error. Here are the steps I've taken. Right click on
How can I set the path for python on Git hook on Windows platform?

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.