• Hello and welcome to our new forums. We upgraded our forum sites to a more robust and modern system which we hope you will enjoy. Be sure to check out your profile by clicking the button on the top right and configure your preferences, signature, time zone, avatar, etc. as you wish. If you need help with using this new forum'ware try the help link on the bottom right.

    Click here to review your account now.

Failed when open a MP4 file with IF statement

jackytank

New member
Joined
Apr 14, 2019
Messages
3
Programming Experience
Beginner
Hi everyone ! I'm a C# beginner and I've wrote my first code in Visual Studio Code ( C# extension included , .NET core SDK debugger )
my code is all about take the input of user then check it whether it's "secret" then it'll open a MP4 files , but something went wrong there I have no idea about , although I tried alot of solutions ...
C#:
using System;
using System.Diagnostics;

namespace Secret
{
    class Find
    {
        static void Main()
        {
            Console.WriteLine("Enter a secret code");
            string line = Console.ReadLine();
            if(line=="secret")
            {
                Process.Start(@"d:\\haha.mp4");
            }
            else
            {
                Console.WriteLine("You will never find my secret hahahahahahaahahahahahahahah");
                Console.ReadLine();
            }
        
        }

    }
}
after I typed "secret" it's appear a dialog :

526




what I done wrong guys ... ? tks for visit my thread
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
2,166
Location
Sydney, Australia
Programming Experience
10+
What happens if you double-click on an MP4 file in File Explorer? Does it open in a default application?
 

JohnH

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
482
Location
Norway
Programming Experience
10+
ProcessStartInfo.UseShellExecute Property (System.Diagnostics) | Microsoft Docs
Property Value said:
true if the shell should be used when starting the process; false if the process should be created directly from the executable file. The default is true on .NET Framework apps and false on .NET Core apps.
Remarks said:
When you use the operating system shell to start processes, you can start any document (which is any registered file type associated with an executable that has a default open action) and perform operations on the file, such as printing, by using the Process object. When UseShellExecute is false, you can start only executables by using the Process object.
 
Top Bottom