How to find path to .cs file by it's type in C#-Collection of common programming errors

All classes get compiled in assemblies (.exe or .dll). I don’t think you can get the path to the source file of a class, because that class might not even exist (if you have copied the .exe file to another machine).

But you can get the path to the current assembly (.exe file) that is running. Check out this answer: Get the Assembly path C#

string file = (new System.Uri(Assembly.GetExecutingAssembly().CodeBase)).AbsolutePath;