MonoDevelop.Projects.Project.AddFile C# (CSharp) Method

AddFile() public method

Adds a file to the project
public AddFile ( string filename ) : ProjectFile
filename string /// Absolute path to the file. ///
return ProjectFile
		public ProjectFile AddFile (string filename)
		{
			return AddFile (filename, null);
		}
		

Same methods

Project::AddFile ( string filename, string buildAction ) : ProjectFile
Project::AddFile ( ProjectFile projectFile ) : void

Usage Example

Example #1
0
        public async Task GetParentFileTest(string inputFile, string expectedParentFile)
        {
            string   solFile = Util.GetSampleProject("console-project", "ConsoleProject.sln");
            Solution sol     = (Solution)await Services.ProjectService.ReadWorkspaceItem(Util.GetMonitor(), solFile);

            Project p   = (Project)sol.Items [0];
            var     dir = p.BaseDirectory;

            string inputFileDestination  = Path.Combine(dir, "FileNesting", inputFile);
            string parentFileDestination = Path.Combine(dir, "FileNesting", expectedParentFile);

            p.AddDirectory("FileNesting");
            p.AddFile(inputFileDestination);
            p.AddFile(parentFileDestination);

            string parentFile = FileNestingService.GetParentFile(p, inputFileDestination);

            Assert.That(parentFile, Is.EqualTo(parentFileDestination), $"Was expecting parent file {parentFileDestination} for {inputFileDestination} but got {parentFile}");

            // Now check we get nothing when parent file doesn't exist
            p.Files.Remove(parentFileDestination);
            parentFile = FileNestingService.GetParentFile(p, inputFileDestination);
            Assert.Null(parentFile, $"Was expecting no parent file for {inputFileDestination} but got {parentFile}");

            sol.Dispose();
        }
All Usage Examples Of MonoDevelop.Projects.Project::AddFile