Hello All,
I am trying to lock some my video, picture, Excel and Word file in my PC by using Visual Basic. I am using Visual Studio 2008 to develop this application but I am unable to do this job.
It'll be something like security utility application. Actually without me, some other people also using my computer and I am trying to lock their access in my personal file.
Can anyone here help me by providing me the Particular code for it? And I wish to know the tools which I can use for this job. I am just a Beginner on this development field. Please help me. I wish to lock individual files in a PC.

Thanks

Dani AI

Generated

Short summary tied to the thread: asked how to lock individual files while others use the same PC. A quick external-tool suggestion from is a valid shortcut; trying to drive a commercial tool’s internal DLLs (as mentioned) is usually fragile and often unsupported. If building a VB.NET utility, there are three practical, reliable approaches — use separate Windows accounts (best practice), enforce NTFS ACLs, or encrypt files and protect keys. (support.microsoft.com)

NTFS permissions (ACLs) — change the file’s access control so only the intended account can read it. This is persistent and OS-native; use the .NET FileSecurity/FileSystemAccessRule APIs to set/remove rules. Example pattern (VB.NET):

Imports System.IO
Imports System.Security.AccessControl

Dim f As New FileInfo("C:\Private\secret.docx")
Dim sec = f.GetAccessControl()
sec.SetAccessRuleProtection(True, False) ' disable inherited rules
sec.AddAccessRule(New FileSystemAccessRule(Environment.UserDomainName & "\" & Environment.UserName, FileSystemRights.FullControl, AccessControlType.Allow))
f.SetAccessControl(sec)

See FileSecurity examples. (learn.microsoft.com)

Encryption options — use Windows EFS for per-user encryption (System.IO.File.Encrypt(path)) when NTFS is available (encrypted files can only be decrypted by the account that encrypted them). Note: administrators/owners and domain recovery policies can override or recover files, so EFS is not a magic bullet against admin access. (learn.microsoft.com)

Application-level encryption + key protection — recommended when users share the same Windows account: encrypt file contents with AES and protect the AES key with DPAPI (ProtectedData.Protect / Unprotect) so the key is tied to the user or machine. For short-lived locks while an app is running, open the file with a FileShare.None FileStream; that prevents other processes from opening it but only while the stream is open. Handle key management, backups, and recovery carefully. (learn.microsoft.com)

Troubleshooting notes: if others log into the same Windows user, only encryption (with separate secrets) or moving files to a different account/profile will stop them. Test on NTFS, handle exceptions for files-in-use, and avoid “roll-your-own” crypto without following safe patterns.

Recommended Answers

All 4 Replies

Try to access the DLL or other componenets of the tool to achieve the same from your own application

I know that but I don't know how to do that by VB.Net? Please help me.

Try to access the DLL or other componenets of the tool to achieve the same from your own application

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.