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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:55:32+00:00 2026-05-25T06:55:32+00:00

I am using Visual Studio 2010 with C#. When I use the Start Debugging

  • 0

I am using Visual Studio 2010 with C#.

When I use the Start Debugging tool (F5) everything seems to work fine. So I build the solution.

Now I close out of Visual Studio 2010 and go to the path where the ‘application’ is kept for the program. When I double click on the file it runs the program fine. However, when I go to click the “save” button in the GUI it saves the files but is being caught by my try/catch block.

Why does this happen in the application when I double click it, but not when I am running Visual Studio 2010 to debug?

EDIT:

try
{
    StreamWriter sw2 = new StreamWriter(saveFile2.FileName);
    List<string> universalLineList = new List<string>();
    string file = saveFile2.FileName;
    string[] splitFile = file.Split('\\');
    string[] savedName = splitfile[6].Split('.');
    int i = 1;

    sw2.WriteLine(savedName[0]);
    sw2.WriteLine("Created on: " + DateTime.Now.ToShortDateString() + " at: " + DateTime.Now.ToString("HH:mm:ss"));
    sw2.WriteLine();

    while (i < stepAndRepeatcounter)
    {
        sw2.WriteLine("Line: {0}", i);
        i++;
    }

    sw.WriteLine();

    foreach(var line in theUniversalList)
    {
        if (line.Name.ToUpper().Contains("FID"))
        {
            sw2.WriteLine("Fiducial: {0}, X: {1}, Y: {2}",
                          line.Name,
                          line.XPlacement,
                          line.YPlacement);
        }
    }

    sw2.WriteLine("Placements: ");

    foreach (var line in theUniversalList)
    {
        if (!line.Name.ToUpper().Contains("FID"))
        {
            sw2.WriteLine("Name: {0}, X: {1}, Y: {2}",
                          line.Name,
                          line.XPlacement,
                          line.YPlacement);
        }
    }

    int j = 0;
    sw2.WriteLine("Slots: ");
    foreach (var line in theUniversalList)
    {
        if (!line.Name.ToUpper().Contains("FID"))
        {
            sw2.WriteLine("Slot: {0}, P/D: {1}, P/N: {2}",
                          j,
                          line.PartDescription,
                          line.PartNumber);

            sw2.WriteLine("Slot: 22, P/D: Reject, P/N: {0}",
                          line.PartNumber);

            j++;
        }
    }

    sw2.Close();
}

catch (Exception)
{
    MessageBox.Show("Could not format and save Universal-1 Placements", "Universal-1 Save Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
  • 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-25T06:55:32+00:00Added an answer on May 25, 2026 at 6:55 am

    I think it’s the following lines:

    string file = saveFile2.FileName;
    string[] splitFile = file.Split('\\');
    string[] savedName = splitfile[6].Split('.');
    

    I guess your path is not long enough for the 7th element, when you are running the file from the command line (maybe the path is then something like “.\xzy.txt”

    To be 100% sure check the StackTrace of the exception too, to get the line with the error.

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

Sidebar

Related Questions

For reference, I'm using Visual Studio 2010. I have a custom build step defined
Using Visual Studio 2010 C++ with googlemock. I'm trying to use a mock I
I'm using Visual Studio 2010 Beta 2 to get a head start on learning
I am using Visual Studio 2010 Ultimate to perform loadtests. These loadtest use recorded
I am using Visual Studio 2010 RC1. I define a resource Brush2 in app.xaml_:
I'm using Visual Studio 2010 RC. Would it be possible that after doing my
I am using Visual Studio 2010 Ultimate Beta 2. What is the relevant namespace/classes
I'm using Visual Studio 2010 RTM with .NET/Entity Framework 4 RTM with a model
I'm running Windows 7 Ultimate (64 bit) using Visual Studio 2010 RC. I recently
I want to be able to develop code using Visual Studio 2010. I just

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.