Roland-2 icon

zexplorer

Roland-2 | PRO | 03/07/16 10:36:07 AM UTC | 0 ⭐ | 220 👁️ | Never ⏰ | []
VB.NET |

3.61 KB

|

None

|

0 👍

/

0 👎

Imports System.IO
 
Module zexplorer
 
    Public Function dirictoryname1(ByVal dirictorypath As String) As String
        Dim currentDirectory As String = dirictorypath
        Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory)
        Dim diectoryoutput As String
        diectoryoutput = newCurrentDirectory.Name
        Return diectoryoutput
    End Function
 
    Public Function dirictoryparentname1(ByVal dirictorypath As String) As String
        Dim currentDirectory As String = dirictorypath
        Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory)
        Dim diectoryoutput As String
        diectoryoutput = newCurrentDirectory.Parent.Name
        Return diectoryoutput
    End Function
 
    Public Function dirictoryback(ByVal dirictorypath As String) As String
        Dim currentDirectory As String = dirictorypath
        Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory)
        Dim diectoryoutput As String
        diectoryoutput = newCurrentDirectory.Parent.FullName
        Return diectoryoutput
    End Function
 
End Module
 
'Return Partial Path Treeview ( onwards from Home Folder ), Read Snippets & txt files
Dim home As String = Application.StartupPath + "\home"
 
 Private Sub explorer_tree_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles explorer_tree.AfterSelect
 
        Dim vCurrentFolder As String = GetFullPathForTreeNode(e.Node)
        Dim Extension As String = Path.GetExtension(vCurrentFolder)
 
        If Extension = ".txt" Or Extension = ".snippet" Then
            If dirictoryparentname1(vCurrentFolder) = "home" Then
                Txtenterpath.Text = dirictoryname1(vCurrentFolder)
            Else
                Txtenterpath.Text = ReturnStringPath(vCurrentFolder)
            End If
 
            Dim str As New StreamReader(vCurrentFolder)
            Dim line As String
            Dim textAll As String = ""
            Dim LastLine As Boolean = False
 
            Do Until LastLine
                line = str.ReadLine()
                If line Is Nothing Then
                    LastLine = True
                Else
                    textAll = textAll & line & vbCrLf 'Chr(13) + chr(10)
                End If
            Loop
            Txtreadwrite.Text = textAll
            str.Close()
            str.Dispose()
        Else
            If dirictoryparentname1(vCurrentFolder) = "home" Then
                Txtenterpath.Text = dirictoryname1(vCurrentFolder)
            Else
                Txtenterpath.Text = ReturnStringPath(vCurrentFolder)
            End If
            Txtreadwrite.Clear()
        End If
 
    End Sub
 
    Public Function ReturnStringPath(ByVal dirictorypath As String) As String
        Dim str3 As New StringBuilder
 
        Dim output As String = ""
            Dim standin1 As String = dirictorypath
        Do Until output = "home"
 
            output = dirictoryname1(standin1)
            If Not output = "home" Then
                str3.Insert(0, output + "\")
            End If
            standin1 = dirictoryback(standin1)
        Loop
        dirictorypath = str3.ToString
            Dim d As Integer
            d = dirictorypath.Length
            dirictorypath = dirictorypath.Remove(d - 1, 1)
 
        Return dirictorypath
    End Function
    End Sub
 Private Sub btnsavetxt_Click(sender As Object, e As EventArgs) Handles btnsavetxt.Click
        My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\home\" + Txtenterpath.Text, Txtreadwrite.Text, False)
    End Sub

Comments