C#:将现有文件添加到项目中的特定文件夹
我需要你们这些了不起的人的帮助。因此,我为Visual Studio 2012制作了一个加载项,它执行以下操作: 当在屏幕上打开.aspx扩展名文件并按下加载项时 1) 它将检查App\u LocalResources文件夹中是否存在资源文件C#:将现有文件添加到项目中的特定文件夹,c#,asp.net,visual-studio-2012,add-in,projects-and-solutions,C#,Asp.net,Visual Studio 2012,Add In,Projects And Solutions,我需要你们这些了不起的人的帮助。因此,我为Visual Studio 2012制作了一个加载项,它执行以下操作: 当在屏幕上打开.aspx扩展名文件并按下加载项时 1) 它将检查App\u LocalResources文件夹中是否存在资源文件 If Resource file exists: It will compare the .aspx file and the resource file and if something is missing in the resour
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\u LocalResources
中创建的!之后,当它将其添加到项目中时,不会将其添加到App\u LocalResources
文件夹下,而是将其添加到Default.aspx
下。我尝试了AddExistingItem
和AddFromFile
,得到了相同的结果。有人能帮我吗
编辑:好,我一直在使用以下代码将文件添加到我的项目中:
var currentObj=\u applicationObject.ActiveDocument代码>
currentObj.ProjectItem.ProjectItems.AddFromFile(文件路径)代码>
因为我正在使用ActiveDocument,所以它将文件添加到文件Default.aspx下,因为我正在处理它。有没有办法改变这一点?可以尝试使用:
currentObj.ProjectItem.ContainingProject