Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#:将现有文件添加到项目中的特定文件夹_C#_Asp.net_Visual Studio 2012_Add In_Projects And Solutions - Fatal编程技术网

C#:将现有文件添加到项目中的特定文件夹

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

我需要你们这些了不起的人的帮助。因此,我为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 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