In first application can be erased file End.ini but in second application it does not. The application displays an Access denied. I use Win32. I do not know what I do. :)
Writes me "Error deleting file: Permission denied" and directory can be determined by users and writes to me in any location Then it writes to a file and second program work with it.
I suspect your access denied error is generated by the system call. You could try forcing a delete by using "erase /F /Q " to force a delete. I wouldn't use this program setup however, it's an enormous security bug to let users erase a directory by force.
There's probably a program active in the directory you are trying to delete. If a program has its working directory in the directory you are to delete, the delete command will fail with an access denied error. Make sure there are no programs running in this directory before you call delete. Of course I can't know for certain, since I do not know what directory you specified.
Is your first program in the directory you are trying to delete? If so, then of course it doesn't work when the first is still active, it has its working directory there.
I believe you are using the wrong command to delete the folder. Windows will only delete empty folders using this command. You can use the RD command (Remove Directory) to delete a directory and all its subfiles. An example:
string B = "RD /S /Q " + Directory;
The /S switch means recursive, it will delete all files in the folder as well as the folder itself.
The /Q switch means quiet, it will not ask the user for confirmation.
This should solve your problem, I tested it on my own PC (Windows 10, 64-bit) and the program deleted the given folder just fine.
For single files you can use the "DEL" command. I thought by the variable name (Directory) that you intended to erase an entire directory, in that case "RD" would solve the problem.