Creating ASP.NET Core File Folder

Asked

Viewed 282 times

2

Hello I am generating a file folder via code, but it n appears as if in fact it is inside the project/solution, like this:

Imagem 1

I would like to create (via code) the file folder so that it is actually within the project/solution. That way:

Imagem 2

Thanks in advance!

  • Both folders are created, but the folder silde you didn’t add it to the project, just created it, while the folder exemplo is as the project folder. This is the difference of both. If you want to put the folder slide in the project, or you put it in the csproj or right-click on it and choose the option Include in Project or something like that.

  • The OP is asking about how to do include via CODE @Tiedttech

1 answer

0


To do this you must instantiate a variable equivalent to your project, add the item to it by identifying its type and save it.

Here’s an example of how to do this:

var proj = new Microsoft.Build.Evaluation.Project(@"C:\projects\Proj\test\test.csproj");
        proj.AddItem("Folder", @"C:\projects\Proj\test\test2");
        proj.AddItem("Compile", @"C:\projects\Proj\test\test2\Class1.cs");
        proj.Save();

Browser other questions tagged

You are not signed in. Login or sign up in order to post.