How can I add an existing file to a project

I have created a file in the project directory. How do I add it to the project so that it show up in the solution explorer and builds?

2 comments
Comment actions Permalink

Try this:

using (var cookie = folder.GetSolution().CreateTransactionCookie(DefaultAction.Commit, "Create file", NullProgressIndicator.Instance))
{
  string reason;

  if (!cookie.CanAddFile(folder, location, out reason))
    return null;

  projectFile = cookie.AddFile(folder, location);
}

1
Comment actions Permalink

Thanks, that worked great!

0

Please sign in to leave a comment.