NotSupportedException: Path was not rooted


Question: How do you solve 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.


Login to See the Rest of the Answer

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 then navigate to the Properties section. See the 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. Build your project again and verify that the file was indeed copied to the Bin Directory.







For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]