NotSupportedException: Path 'wwwroot myfolder filename.txt' was not rooted


Question: How do you solve for the error in Asp.Net 6 that says "NotSupportedException: Path 'wwwroot\myfolder\filename.txt' was not rooted" An unhandled exception occurred while processing the request?


Login to See the Rest of the Answer

Answer:
Chances are that you are trying to use the path to the directory in your project but then the path is not all the way complete. Asp.Net 6 Runtime would like to know the complete path starting from the Root Directory such as the "C" or "D" drive. In this case, you only provided "\wwwroot\myfolder\filename.txt" and the compiler got confused.

How to solve this error:
1. Just add

Path.GetFullPath(Url.Content(Path.Combine("wwwroot,"myfolder","filename.txt")));






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