Home > front end >  vb.net set windows.old folder permission
vb.net set windows.old folder permission

Time:10-29

    Dim myDirectoryInfo As DirectoryInfo = New DirectoryInfo("C:\Windows.old")
    Dim myDirectorySecurity As DirectorySecurity = myDirectoryInfo.GetAccessControl()
    Dim User As String = "Everyone"
    myDirectorySecurity.AddAccessRule(New FileSystemAccessRule(User, FileSystemRights.FullControl, InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
    myDirectoryInfo.SetAccessControl(myDirectorySecurity)

I have a program that deletes junk files on the computer. I want to delete the files in windows.old but the above code doesn't work. Can you help me?

CodePudding user response:

Windows.old is created and maintained for a short period of time in case you want to roll back to a previous install. It normally contains all the files from a previous install.

It should go away by itself, but if not, go to Settings, System, storage and click on the drive at the top of the page. Run down to Temporary files and it should be listed as Previous version of Windows. See if you can delete it there.

If you have deleted parts of it manually, no telling what it will do.

I would not recommend writing code to handle this as it isn't a folder that should come back after you deal with it once.

  • Related