Console application works when "F5" the page but not when clicking "ConsoleApp.exe"

This is a discussion on Console application works when "F5" the page but not when clicking "ConsoleApp.exe" within the C# Programming forums, part of the General Programming Boards category; Hi, I have created a console application with a little code that creates a file. The code works fine when ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    383

    Console application works when "F5" the page but not when clicking "ConsoleApp.exe"

    Hi,

    I have created a console application with a little code that creates a file.
    The code works fine when debugging with F5 but when I try to execute the file by doubleclick it, nothing happens:

    File that I try to doubleclick:
    ..My Documents\Visual Studio 2010\Projects\ConsoleApp\ConsoleApp\bin\Release\Co nsoleApp.exe

    I wonder if I miss something out?
    Casino Reviews - Over 100 Online Casino Reviews.
    Free Roulette Software - Free Roulette Software & complete betting tool for roulette. Simulate any systems.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    383
    This is the code I have in the application. It only runs when debugging with F5, but not when doubleclick the .exe file in the release folder?
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.IO;
    
    namespace consoleApp
    {
        class Program
        {
            static void Main(string[] args)
            {
    
                FileStream hr = new FileStream("D:/test.txt", FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
                StreamWriter file1 = new StreamWriter(hr); 
                file1.WriteLine("testString"); file1.Close(); hr.Close();
    
            } //static void Main(string[] args)
        }
    }
    Casino Reviews - Over 100 Online Casino Reviews.
    Free Roulette Software - Free Roulette Software & complete betting tool for roulette. Simulate any systems.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    This looks like C#
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Jun 2003
    Posts
    129
    Have you checked the test.txt file? The command window can go astonishingly fast sometimes. Maybe try adding a DateTime.Now.ToString() to the writeline just to check.
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

  5. #5
    Registered User
    Join Date
    Dec 2007
    Posts
    383
    Yes you are right, I did some kind of mistake by forgetting to take "Build Solution" F6 and not only F5. When doing that the new changes
    was also made to the .exe file itself. So I think it is solved now.

    Thank you for help
    Casino Reviews - Over 100 Online Casino Reviews.
    Free Roulette Software - Free Roulette Software & complete betting tool for roulette. Simulate any systems.

  6. #6
    Registered User
    Join Date
    Jun 2003
    Posts
    129
    Also forgot to mention that command windows under normal conditions don't have the "press any key ... " at the end. Dead easy to add.

    Code:
    Console.WriteLine();
    Console.Write("Press any key to exit ...");
    Console.ReadKey();
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 08-19-2012, 07:15 AM
  2. Replies: 9
    Last Post: 03-31-2009, 05:23 PM
  3. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  4. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21