I just downloaded Minecraft. When I pushed play, it finished, but then it loaded again. So I tried to delete the .minecraft folder, but it said the file is open in another program.
Restart your computer, this should stop the process that is using the .minecraft folder so you can delete it.
Close completely every minecraft related program, then retry. You can't delete something if its data is being used by something else.
Open an elevated cmd (run as administrator)
In the command prompt, type
list volumeand press Enter.
This will let you see what the drive letter is for the drive that you want to delete the folder in since it may not always be the same drive letter that it is in Windows.
After making note of the drive letter, type
exitand press Enter.
In the command prompt, type the command below and press Enter.
RD /S /Q "Full Path of Folder"
Full Path of Folderwithin quotes below with your folder's full path within quotes instead.
For example, if I wanted to delete a folder named Folder on my desktop, I would type this command below.
RD /S /Q "C:\Users\UserName\Desktop\Folder"
The folder should now be deleted. Close the command prompt.
If you used a command prompt at boot, then also close the System Recovery Options window and restart the computer.
I use this software to delete these kinda "Hard-to-Delete" files.
Just right click on the file and select its option. You can then either kill the process using it, or move the file, or have it deleted.
Hope this helps!