开发者

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 Class2

I 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜