【发布时间】:2013-07-08 09:04:15
【问题描述】:
我需要你们这些了不起的人的帮助。所以我为 Visual Studio 2012 制作了一个插件,它执行以下操作:
当 .aspx 扩展名文件在屏幕上打开并按下加载项时
1) 它会检查 App_LocalResources 文件夹中是否已经存在资源文件
If Resource file exists:
It will compare the .aspx file and the resource file and if something
is missing in the resource file it will add it
If Resource file does not exist:
First it will create a new resource file. After that it will check
the meta:resourcekeys on the aspx file and add them to the resource file
after that it should add the file to the project under the
App_LocalResources folder
这就是我卡住的地方。当我使用AddFromFile 时,它总是会在 .aspx 文件下添加该文件。因此,假设我正在处理一个名为Default.aspx 的页面,然后按下我的加载项。我的加载项会找到meta:resourcekeys 并将它们添加到新创建的资源文件中,该文件实际上是在文件夹App_LocalResources 中创建的!之后将其添加到项目中时,它不会将其添加到App_LocalResources 文件夹下,而是将其添加到Default.aspx 下。我尝试了AddExistingItem 和 AddFromFile,结果相同。谁能帮帮我?
编辑:好的,所以我一直在使用此代码将文件添加到我的项目中:
var currentObj = _applicationObject.ActiveDocument;
currentObj.ProjectItem.ProjectItems.AddFromFile(FilePath);
由于我使用的是 ActiveDocument,它会在文件 Default.aspx 下添加文件 ,因为我正在处理它。有什么办法可以改变吗?
【问题讨论】:
标签: c# asp.net visual-studio-2012 add-in projects-and-solutions