How to get the current executable name in C#

1 Answer

0 votes
using System;
using System.IO;

class Program
{
    static void Main()
    {
        var path = Environment.CommandLine;
        
        var s = Path.GetFileName(path);

        Console.WriteLine(s);
    }
}


 
/*
run:
 
Main.exe
 
*/

 



answered Jun 3, 2025 by avibootz

Related questions

2 answers 103 views
1 answer 134 views
1 answer 120 views
1 answer 160 views
1 answer 164 views
2 answers 149 views
1 answer 137 views
...