Advertisement
Roland-2

zexplorer

Mar 7th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 3.61 KB | None | 0 0
  1. Imports System.IO
  2.  
  3. Module zexplorer
  4.  
  5.     Public Function dirictoryname1(ByVal dirictorypath As String) As String
  6.         Dim currentDirectory As String = dirictorypath
  7.         Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory)
  8.         Dim diectoryoutput As String
  9.         diectoryoutput = newCurrentDirectory.Name
  10.         Return diectoryoutput
  11.     End Function
  12.  
  13.     Public Function dirictoryparentname1(ByVal dirictorypath As String) As String
  14.         Dim currentDirectory As String = dirictorypath
  15.         Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory)
  16.         Dim diectoryoutput As String
  17.         diectoryoutput = newCurrentDirectory.Parent.Name
  18.         Return diectoryoutput
  19.     End Function
  20.  
  21.     Public Function dirictoryback(ByVal dirictorypath As String) As String
  22.         Dim currentDirectory As String = dirictorypath
  23.         Dim newCurrentDirectory As DirectoryInfo = New DirectoryInfo(currentDirectory)
  24.         Dim diectoryoutput As String
  25.         diectoryoutput = newCurrentDirectory.Parent.FullName
  26.         Return diectoryoutput
  27.     End Function
  28.  
  29. End Module
  30.  
  31. 'Return Partial Path Treeview ( onwards from Home Folder ), Read Snippets & txt files
  32. Dim home As String = Application.StartupPath + "\home"
  33.  
  34.  Private Sub explorer_tree_AfterSelect(sender As System.Object, e As System.Windows.Forms.TreeViewEventArgs) Handles explorer_tree.AfterSelect
  35.  
  36.         Dim vCurrentFolder As String = GetFullPathForTreeNode(e.Node)
  37.         Dim Extension As String = Path.GetExtension(vCurrentFolder)
  38.  
  39.         If Extension = ".txt" Or Extension = ".snippet" Then
  40.             If dirictoryparentname1(vCurrentFolder) = "home" Then
  41.                 Txtenterpath.Text = dirictoryname1(vCurrentFolder)
  42.             Else
  43.                 Txtenterpath.Text = ReturnStringPath(vCurrentFolder)
  44.             End If
  45.  
  46.             Dim str As New StreamReader(vCurrentFolder)
  47.             Dim line As String
  48.             Dim textAll As String = ""
  49.             Dim LastLine As Boolean = False
  50.  
  51.             Do Until LastLine
  52.                 line = str.ReadLine()
  53.                 If line Is Nothing Then
  54.                     LastLine = True
  55.                 Else
  56.                     textAll = textAll & line & vbCrLf 'Chr(13) + chr(10)
  57.                 End If
  58.             Loop
  59.             Txtreadwrite.Text = textAll
  60.             str.Close()
  61.             str.Dispose()
  62.         Else
  63.             If dirictoryparentname1(vCurrentFolder) = "home" Then
  64.                 Txtenterpath.Text = dirictoryname1(vCurrentFolder)
  65.             Else
  66.                 Txtenterpath.Text = ReturnStringPath(vCurrentFolder)
  67.             End If
  68.             Txtreadwrite.Clear()
  69.         End If
  70.  
  71.     End Sub
  72.  
  73.     Public Function ReturnStringPath(ByVal dirictorypath As String) As String
  74.         Dim str3 As New StringBuilder
  75.  
  76.         Dim output As String = ""
  77.             Dim standin1 As String = dirictorypath
  78.         Do Until output = "home"
  79.  
  80.             output = dirictoryname1(standin1)
  81.             If Not output = "home" Then
  82.                 str3.Insert(0, output + "\")
  83.             End If
  84.             standin1 = dirictoryback(standin1)
  85.         Loop
  86.         dirictorypath = str3.ToString
  87.             Dim d As Integer
  88.             d = dirictorypath.Length
  89.             dirictorypath = dirictorypath.Remove(d - 1, 1)
  90.  
  91.         Return dirictorypath
  92.     End Function
  93.     End Sub
  94.  Private Sub btnsavetxt_Click(sender As Object, e As EventArgs) Handles btnsavetxt.Click
  95.         My.Computer.FileSystem.WriteAllText(Application.StartupPath + "\home\" + Txtenterpath.Text, Txtreadwrite.Text, False)
  96.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement