Home > Articles > Details

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?


Please 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")));


If you log in, you will be notified when someone leaves a comment.

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


© 2022 - ErnesTech - Privacy