Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' form1
- Public Class Form1
- Public path As String
- Public nazwapliku
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ' Zapisuje tekst
- If TextBox1.Text = "" Then
- MsgBox("Nazwij notatkę!")
- Else
- My.Computer.FileSystem.WriteAllText(path & ("/") & TextBox1.Text & (".txt"), RichTextBox1.Text, False)
- End If
- ' ponownie sprawdza pliki w folderze
- Dim fileNames = My.Computer.FileSystem.GetFiles(path, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
- ListBox1.Items.Clear()
- For Each fileName As String In fileNames
- Dim nazwapliku As String = My.Computer.FileSystem.GetName(fileName)
- nazwapliku = nazwapliku.Remove(nazwapliku.Length - 4)
- ListBox1.Items.Add(nazwapliku)
- Next
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'sprawdza czy jest to pierwsze uruchomienie
- If My.Computer.FileSystem.FileExists(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "/notatki.txt") Then
- path = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "/notatki.txt") & "\"
- 'wczytuje pliki z path do listboxa
- Dim fileNames = My.Computer.FileSystem.GetFiles(path, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
- ListBox1.Items.Clear()
- For Each fileName As String In fileNames
- Dim nazwapliku As String
- nazwapliku = My.Computer.FileSystem.GetName(fileName)
- nazwapliku = nazwapliku.Remove(nazwapliku.Length - 4)
- ListBox1.Items.Add(nazwapliku)
- Next
- Else
- Form2.Show()
- End If
- End Sub
- Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
- ' wyświetla tekst po wybraniu itemu w itemboxie
- RichTextBox1.Text = My.Computer.FileSystem.ReadAllText(path & ListBox1.SelectedItem & ".txt")
- TextBox1.Text = ListBox1.SelectedItem
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- ' usuwa wybrany plik
- Dim result As Integer = MessageBox.Show("Po usunięciu pliku nie będzie można odzyskać Usunąć?", "Usunąć?", MessageBoxButtons.YesNo)
- If result = DialogResult.Yes Then
- My.Computer.FileSystem.DeleteFile(path & ListBox1.SelectedItem & ".txt")
- TextBox1.Text = ""
- End If
- ' refresh listboxa
- Dim fileNames = My.Computer.FileSystem.GetFiles(path, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
- ListBox1.Items.Clear()
- For Each fileName As String In fileNames
- nazwapliku = My.Computer.FileSystem.GetName(fileName)
- nazwapliku = nazwapliku.Remove(nazwapliku.Length - 4)
- ListBox1.Items.Add(nazwapliku)
- Next
- End Sub
- Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
- RichTextBox1.Text = ""
- End Sub
- Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
- ' zmienia nazwę notatki
- If TextBox1.Text = ListBox1.SelectedItem Then
- MsgBox("Zmień nazwę notatki!")
- Else
- My.Computer.FileSystem.RenameFile(path & ListBox1.SelectedItem & ".txt", TextBox1.Text & ".txt")
- End If
- ' refresh listboxa
- Dim fileNames = My.Computer.FileSystem.GetFiles(path, FileIO.SearchOption.SearchTopLevelOnly, "*.txt")
- ListBox1.Items.Clear()
- For Each fileName As String In fileNames
- nazwapliku = My.Computer.FileSystem.GetName(fileName)
- nazwapliku = nazwapliku.Remove(nazwapliku.Length - 4)
- ListBox1.Items.Add(nazwapliku)
- Next
- End Sub
- Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
- Form2.Show()
- End Sub
- Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
- TextBox1.Text = ""
- RichTextBox1.Text = ""
- End Sub
- End Class
- 'form2
- Public Class Form2
- Public path As String
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ' wybieranie miejsca zapisu
- FolderBrowserDialog1.ShowDialog()
- TextBox1.Text = FolderBrowserDialog1.SelectedPath
- path = FolderBrowserDialog1.SelectedPath
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- ' sprawdza poprawność
- If path = "" Then
- MsgBox("Wybierz miejsce zapisu!")
- Else
- ' zapisuje do ścieżkę do pliku
- My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "/notatki.txt", path, False)
- path = FolderBrowserDialog1.SelectedPath
- Me.Close()
- Form1.Show()
- End If
- End Sub
- Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
- MsgBox("E-mail do twórcy: mateusz1239196@gmail.com")
- End Sub
- Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Form1.Hide()
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement