public static bool TryAddItem(IVsProject project, string path) { var item = project.GetProjectItem(path); if (item == null) { project.EnsureIsCheckout(); if (!Directory.Exists(Path.GetDirectoryName(path))) { Directory.CreateDirectory(Path.GetDirectoryName(path)); } if (!File.Exists(path)) { File.Create(path).Dispose(); } // // Check again in case the item gets auto included once the file // has been created // item = project.GetProjectItem(path); if (item == null) { project.AddFromFile(path); } return(true); } return(false); }