Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the C# version of your code:</p> <pre><code>public static void IncludeNewFiles() { int count = 0; EnvDTE80.DTE2 dte2; List&lt;string&gt; newfiles; dte2 = (EnvDTE80.DTE2)System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.10.0"); foreach (Project project in dte2.Solution.Projects) { if (project.UniqueName.EndsWith(".csproj")) { newfiles = GetFilesNotInProject(project); foreach (var file in newfiles) project.ProjectItems.AddFromFile(file); count += newfiles.Count; } } dte2.StatusBar.Text = String.Format("{0} new file{1} included in the project.", count, (count == 1 ? "" : "s")); } public static List&lt;string&gt; GetAllProjectFiles(ProjectItems projectItems, string extension) { List&lt;string&gt; returnValue = new List&lt;string&gt;(); foreach(ProjectItem projectItem in projectItems) { for (short i = 1; i &lt;= projectItems.Count; i++) { string fileName = projectItem.FileNames[i]; if (Path.GetExtension(fileName).ToLower() == extension) returnValue.Add(fileName); } returnValue.AddRange(GetAllProjectFiles(projectItem.ProjectItems, extension)); } return returnValue; } public static List&lt;string&gt; GetFilesNotInProject(Project project) { List&lt;string&gt; returnValue = new List&lt;string&gt;(); string startPath = Path.GetDirectoryName(project.FullName); List&lt;string&gt; projectFiles = GetAllProjectFiles(project.ProjectItems, ".cs"); foreach (var file in Directory.GetFiles(startPath, "*.cs", SearchOption.AllDirectories)) if (!projectFiles.Contains(file)) returnValue.Add(file); return returnValue; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload