This will occur only if you are dealing with "Selenium" projects.
I was having trouble renaming the project and the project folder/directory.
I tried everything mentioned above and I was successfully able to change the name of the project but for some reason, I was not able to change the name of the project folder/directory. It was always throwing an error "[enter image description here][1] [1]: https://i.sstatic.net/Qs9RbZ3n.png "
If you are facing this issue you can resolve this, by following steps. Open task manager > Close all the instances of "chromedriver/any_driver_you_are_using" > Try Renaming the project file now. It should work.