none
Can Someone explain this? RRS feed

  • Question

  • I just want someone to explain this code to me 

        Private Sub ButtonLock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLock.Click
            status = arr(0)
    
            If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
                Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath)
                Dim selectedpath As String = d.Parent.FullName + d.Name
    
                ProgressBar1.Value = 40
    
                If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then
                    If (Not d.Root.Equals(d.Parent.FullName)) Then
                        d.MoveTo(d.Parent.FullName & "\" & d.Name & status)
                    Else
                        d.MoveTo(d.Parent.FullName + d.Name & status)
                    End If
    
                    TextBox1.Text = FolderBrowserDialog1.SelectedPath
                    ProgressBar1.Value = 75
                    ProgressBar1.Value = 100
                Else
    
                    status = getstatus(status)
                    d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")))
                    TextBox1.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))
    
                End If
            End If
    
        End Sub
    
    


    • Moved by CoolDadTx Thursday, July 26, 2018 5:47 PM Not a C# question
    • Edited by Paul IshakModerator Thursday, July 26, 2018 7:12 PM put code into block
    Thursday, July 26, 2018 5:23 PM

All replies

  • Hi

    I just want someone to explain this code to me ....

    status = arr(0)
    What is Arr contents?


    Regards Les, Livingston, Scotland

    Thursday, July 26, 2018 6:05 PM
  • I'm not sure what you want to know, and some of the code doesn't really make any sense or refers to other code that's not supplied.

    In short, it appears to be code that moves a folder but it isn't clear what the intended logic of the move is supposed to be... particularly what purpose "status" serves, why the progress bar is being used the way it is, why "selectedpath" is being constructed, what ".{" is supposed to indicate in a path name, or what the "getstatus()" method is for.

    There just doesn't seem to be enough to go on to try to give you any overarching explanation of this code.


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Thursday, July 26, 2018 6:11 PM
    Moderator
  •     Private Sub Folder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            status = ""
            arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
            arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}"
            arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}"
            arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}"
            arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}"
            arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
        End Sub
    Thursday, July 26, 2018 6:13 PM
  •     Private Sub Folder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            status = ""
            arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
            arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}"
            arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}"
            arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}"
            arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}"
            arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
        End Sub

    Hi

    ..... and ....... what about getstatus(Status)?

    Do we really need to do all this in little snippets?


    Regards Les, Livingston, Scotland

    Thursday, July 26, 2018 6:47 PM
  • Imports System.IO Imports System.Drawing Imports System.Windows.Forms Public Class Form1 Public status As String Private arr As String() = New String(5) {} Private Sub Folder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load status = "" arr(0) = ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}" arr(1) = ".{21EC2020-3AEA-1069-A2DD-08002B30309D}" arr(2) = ".{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}" arr(3) = ".{645FF040-5081-101B-9F08-00AA002F954E}" arr(4) = ".{2559a1f1-21d7-11d4-bdaf-00c04f60b9f0}" arr(5) = ".{7007ACC7-3202-11D1-AAD2-00805FC1270E}" End Sub Private Sub ButtonLock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLock.Click status = arr(0) If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath) Dim selectedpath As String = d.Parent.FullName + d.Name ProgressBar1.Value = 40 If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then If (Not d.Root.Equals(d.Parent.FullName)) Then d.MoveTo(d.Parent.FullName & "\" & d.Name & status) Else d.MoveTo(d.Parent.FullName + d.Name & status) End If txtBrowse.Text = FolderBrowserDialog1.SelectedPath ProgressBar1.Value = 75 ProgressBar1.Value = 100 Else status = getstatus(status) d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))) txtBrowse.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")) End If End If End Sub Private Sub ButtonUnlock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonUnlock.Click status = arr(1) If FolderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Dim d As DirectoryInfo = New DirectoryInfo(FolderBrowserDialog1.SelectedPath) Dim selectedpath As String = d.Parent.FullName + d.Name ProgressBar1.Value = 40 ProgressBar1.Value = 100 If FolderBrowserDialog1.SelectedPath.LastIndexOf(".{") = -1 Then d.MoveTo(d.Parent.FullName & "\" & d.Name & status) If (Not d.Root.Equals(d.Parent.FullName)) Then Else d.MoveTo(d.Parent.FullName + d.Name & status) End If txtUnBrowse.Text = FolderBrowserDialog1.SelectedPath ProgressBar1.Value = 100 ProgressBar1.Value = 100 Else status = getstatus(status) d.MoveTo(FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf("."))) txtUnBrowse.Text = FolderBrowserDialog1.SelectedPath.Substring(0, FolderBrowserDialog1.SelectedPath.LastIndexOf(".")) End If End If End Sub Private Function getstatus(ByVal stat As String) As String For i As Integer = 0 To 5 If stat.LastIndexOf(arr(i)) <> -1 Then stat = stat.Substring(stat.LastIndexOf(".")) End If Next i Return stat End Function Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click txtBrowse.Clear() End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click txtUnBrowse.Clear() End Sub Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click Me.Close() End Sub End Class

    all of the code, its i guess a folder locker, i found it and im just confused

    Friday, July 27, 2018 6:39 AM
  • Hi

    i think you are right, some sort of folder lock/hide type thing. See HERE for a little information.

    However, I really can't see the need for the code you show to do this - seems a little 'odd' to me.


    Regards Les, Livingston, Scotland

    Friday, July 27, 2018 12:26 PM