0

I am making a little program and I need to be able to remove the Lock attribute from all files (no matter the extension of those files) in the specified directory. I haven't find any way to do so on the web so far, so I really have no idea how to start a basic code for that job, so all I can really do is give you the elements of my Windows Form:

  • txtDirectory: This is where the directory is being displayed/selected. All files in the displayed directory needs to be getting the Lock attribute from them - see btnConfirm to know more.
  • btnSelectDirectory: This button opens the directory seletion dialog. This section does not need any code - but feel free to add code if you think it could improve my program.
  • btnConfirm: This button is where, when clicked, all files in the specified directory will be removed from the Lock attribute. This is what I really need help with.

How can I do so?

  • 1
    I searched for `VB.Net Remove Lock File Attribute` and found many hits. This was near the top of the list: https://stackoverflow.com/a/7399663/70104 – Chris Dunaway Jan 28 '20 at 14:34
  • What is Lock *attribute* referred to, the `NTFS Alternate Data Streams`, by chance? Visibly active on a file when, for example, the file comes from another machine in a network? – Jimi Jan 28 '20 at 15:53
  • @Jimi No I am talking about the little lock attribute that the downloaded files have. This attribute sort of block some features (like editing the files, etc.) and can be disabled when opening the property window of a file by right clicking on the file and selecting the **Properties** option. – Velocity DK Jan 28 '20 at 15:56
  • 1
    Yes, that's generated by the [NTFS `Alternate Data Streams (ADS)`](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/b134f29a-6278-4f3f-904f-5e58a713d2c5). – Jimi Jan 28 '20 at 15:58
  • @Jimi Ok, do you know how I can disable that lock feature in VB.Net? All of the results I have found are either in C# or CMD/Batch. – Velocity DK Jan 28 '20 at 15:59
  • 1
    As a simple solution, you can execute SysInternals' [Streams Utility](https://learn.microsoft.com/en-us/sysinternals/downloads/streams) to remove all ADS from all files in a path and optionally, sub-paths. It's silent, so you can just `Process.Start()` it. Or redirect the output, to log/read the list of files that have been affected. – Jimi Jan 28 '20 at 16:01
  • @Jimi This works flawlessly, thank you! – Velocity DK Jan 28 '20 at 16:04
  • @VelocityDK You might find [NTFS Alternate Data Streams - .NET](https://stackoverflow.com/q/604960/1115360) useful if you want to keep it entirely within your own program. – Andrew Morton Jan 28 '20 at 16:42
  • 1
    @AndrewMorton Yeah, that's what I just figured. Thanks for the help! :) – Velocity DK Jan 28 '20 at 16:47

0 Answers0