简体   繁体   中英

How to get project name of file in visual studio add-in?

I try to create an add-in which you can make some operations on file you work on (.cs and .aspx files)

I want to access project name of that file.

I tried these codes but I can't find what I want.

_applicationObject.Solution.FullName.ToString()
_applicationObject.ActiveDocument.FullName.ToString()
_applicationObject.ActiveWindow.Document.FullName.ToString()

Projects projects = _applicationObject.ActiveSolutionProjects as Projects;
Project project = null;
if (projects != null)
{
    if (projects.Count > 0)
    {
        project = projects.Item(0);
    }
}
Clipboard.SetText(project.UniqueName);

Name of the project is not a thing that stored in the project description. You need to locate the project file. Name of the project file without the extension is the project name.

If you want to access root namespace or assembly name that's another thing, let me know and I'll explain it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM