11 Replies - 315 Views - Last Post: 21 February 2019 - 05:33 PM Rate Topic: -----

#1 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 01:54 AM

 Dim labelsinfo As String = File.ReadAllText(Application.StartupPath + "/Folder Locked/FolderLocation.txt")
                Dim labels_1 As String() = labelsinfo.Split("%")
                Dim value As List(Of String) = labels_1.ToList()
                Dim x As String
                For Each x In value
                    fs = File.GetAccessControl(x)
                    fs.AddAccessRule(New FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Deny))
                    File.SetAccessControl(x, fs)
                Next



//Coz my code didn't run. help guys :)Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: VB.net: unlocking folder that is the path stored in Notepad

#2 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6744
  • View blog
  • Posts: 27,758
  • Joined: 12-December 12

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 02:04 AM

Why is there a percent sign in your posted code but a comma in the screenshot?

What does 'value' contain when run? What is the value of x when it fails?
Was This Post Helpful? 0
  • +
  • -

#3 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 02:16 AM

View Postandrewsw, on 21 February 2019 - 02:04 AM, said:

Why is there a percent sign in your posted code but a comma in the screenshot?

What does 'value' contain when run? What is the value of x when it fails?


"%" and "," those are my separator, i tried those. I changed to percent sign thought to be good separator than coma, but same ERROR.

In notepad I have this paths " C:\Users\Acer\Desktop\Sample%C:\Users\Acer\Desktop\install step% "

The Value of x when I try to compile without the line of code that can unlock is

" C:\Users\Acer\Desktop\Sample" , " C:\Users\Acer\Desktop\install step"
and this blank
Attached Image
Was This Post Helpful? 0
  • +
  • -

#4 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 02:24 AM

What is your other way of getting the value on Notepad Sirs?

This post has been edited by andrewsw: 21 February 2019 - 02:27 AM
Reason for edit:: removed unnecessary quote, use the Reply button

Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6744
  • View blog
  • Posts: 27,758
  • Joined: 12-December 12

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 02:26 AM

Are the extra spaces problematic?

It appears that you are providing folder names, rather than filenames? Or are they files without extensions...
Was This Post Helpful? 0
  • +
  • -

#6 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 03:07 AM

View Postandrewsw, on 21 February 2019 - 02:26 AM, said:

Are the extra spaces problematic?

It appears that you are providing folder names, rather than filenames? Or are they files without extensions...


I guess the extra spaces that appear in loop.
I just want to unlock the paths that I saved in notepad one by one using for loop
What are the other ways in getting the value of the notepad one by one?
Was This Post Helpful? 0
  • +
  • -

#7 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6744
  • View blog
  • Posts: 27,758
  • Joined: 12-December 12

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 03:37 AM

You are already getting the values. You are reading the text and splitting Split() the text on commas. How you read this text is not the issue. There is a problem with either

the split failing,
needing to remove spaces,
some problem with the filenames

etc.

Remove the redundant spaces in the text file to test. If it works then you have isolated the issue and can write some additional code to trim the spaces.
Was This Post Helpful? 0
  • +
  • -

#8 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 04:32 AM

View Postandrewsw, on 21 February 2019 - 03:37 AM, said:

You are already getting the values. You are reading the text and splitting Split() the text on commas. How you read this text is not the issue. There is a problem with either

the split failing,
needing to remove spaces,
some problem with the filenames

etc.

Remove the redundant spaces in the text file to test. If it works then you have isolated the issue and can write some additional code to trim the spaces.


// i guess i solve it but i have another problem :D
Dim labelsinfo As String = File.ReadAllText(Application.StartupPath + "/Folder Locked/FolderLocation.txt")
                Dim labels_1 As String() = labelsinfo.Split("%")
                Dim value As List(Of String) = labels_1.ToList()
                Dim x As String
                For Each x In value
                    If x = Nothing Then
                        GoTo xy
                    End If
                    fs = File.GetAccessControl(x)

                    fs.RemoveAccessRule(New FileSystemAccessRule(Environment.UserName, FileSystemRights.FullControl, AccessControlType.Deny))
                    File.SetAccessControl(x, fs)

                Next
xy:


Was This Post Helpful? 0
  • +
  • -

#9 andrewsw   User is offline

  • Stealth IT
  • member icon

Reputation: 6744
  • View blog
  • Posts: 27,758
  • Joined: 12-December 12

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 05:09 AM

What other problem?
Was This Post Helpful? 0
  • +
  • -

#10 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 05:18 AM

View Postandrewsw, on 21 February 2019 - 05:09 AM, said:

What other problem?


I posted new :D
Was This Post Helpful? 0
  • +
  • -

#11 IronRazer   User is offline

  • Custom Control Freak
  • member icon

Reputation: 1533
  • View blog
  • Posts: 3,861
  • Joined: 01-February 13

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 03:19 PM

Just so that you are aware, you are really not 'locking' or 'unlocking' the folders or files when you set or remove the Deny access rule. The user can simply right click on the folder or file in an explorer window and remove the Deny access rule through the Properties/Security tab.
Also, it is only the current user that you are blocking access for so, if the folder is in a shared folder where another user on a network, or just another user logged in on your computer has access to, they will have full access to the folder or file.

There really is no way to completely stop a user from finding and gaining access to your folder or file. So, about the only easy way you can secure your files is to encrypt the files or make your own algorithm to scramble the file before saving it. Then you can read the files back in and unscramble/decrypt them when needed. There are a few ways to do this but, no other application would be able to use the files unless it is one you created that knows how to unscramble/decrypt them.
Was This Post Helpful? 1
  • +
  • -

#12 Jcanaria2   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 03-January 19

Re: VB.net: unlocking folder that is the path stored in Notepad

Posted 21 February 2019 - 05:33 PM

Wow! Thank you (bow)
my Thesis project description is just to unlock and lock only by using Face Recognition. I can't add any features but it will give me really a big help.

This post has been edited by andrewsw: 22 February 2019 - 01:35 AM
Reason for edit:: removed previous quote, just use the Reply button

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1