Get C# type from file name
I have a bunch of files in a directory:
Class1.ascx : con开发者_如何学Gotains class Class1
Class2.ascx : contains class Class2I have a list of the file names, and I want to take each filename and identify the corresponding class.
foreach(var fileName in listOfFileNames)
{
...
Type t = MagicMethod(fileName)
...
}
Anyone know what MagicMethod would look like or if it is even possible to do?
The filename could be different than the classname. The file may not even contain a class.
You would have to parse the file.
Here is a parser on codeplex.
精彩评论