NotSupportedException: Path "wwwroot\MyFolder\MyFileName.Extension" was not rooted

Question: How do you solve for an error in MVC AspNet 6 using Visual Studio 2022 that says "NotSupportedException: Path "wwwroot\MyFolder\MyFileName.Extension" was not rooted"? I am trying to download a file from this Folder Location.

Answer: When you are trying to download a file from a wwwroot folder make sure that you have right-clicked on the file in Visual Studio  Solution Explorer and navigate to the Properties section. See steps below:

1. Navigate to Visual Studio 2022 Solution Explorer Section tab or Window.
2. Find the File you would want to access or download when the application gets started (on startup or runtime).
3. Right-click on the file and navigate to Properties Menu.
4. From the Slide-Out menu that shows up, select "Copy Always" on the Lable "Copy to Output Directory".

5. Bould your project again and verify that the file was indeed copied to the Bin Directory.

Other Similar Article

Edit this Article
Visual Studio 2022 MVC AspNet 6 ebook e-book .NET 6 published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy