Skocz do zawartości
  • 👋 Witaj na MPCForum!

    Przeglądasz forum jako gość, co oznacza, że wiele świetnych funkcji jest jeszcze przed Tobą! 😎

    • Pełny dostęp do działów i ukrytych treści
    • Możliwość pisania i odpowiadania w tematach
    • System prywatnych wiadomości
    • Zbieranie reputacji i rozwijanie swojego profilu
    • Członkostwo w jednej z największych społeczności graczy

    👉 Dołączenie zajmie Ci mniej niż minutę – a zyskasz znacznie więcej!

    Zarejestruj się teraz

Visual basic 2010 Prośba o kod + Problem


Rekomendowane odpowiedzi

Opublikowano

Mam Taki Problem Otóż Potrzebuje kodu do visual basic 2010 A dokładniej Potrzebuje kodu Na Usuwanie Folderu Wypełnionego Plikami bez zapytania i informacji

 

Otóż Mam Progressbar1 button1 i Timer1, i kilka innych rzeczy Które nie dotyczą problemu

 

I bym chciał żeby ten folder usuwał się jak bedzie 100 % progressbar1 to znaczy jak bedzie cały pasek ładowania

Tylko że nie znam kodu na usuniecie folderu  i jest jeden problem jak jest na przykład Jest taka Ścieszka 

C:\Users\AGA\AppData\Roaming\.minecraft

 

To jak zrobić żeby Nie było tego "AGA"

 

Bo jak dam taką Ścieszkę to Będzie To Tylko U mnie działać i Próbowałem zrobić C:\Users\%USERNAME%\AppData\Roaming\.minecraft Albo                                                                           C:\Users\%userprofile%\AppData\Roaming\.minecraft   albo %userprofile%\AppData\Roaming\.minecraft albo .minecraft

 

I nie działa

 

Szukałem na necie i nie ma proszę o pomoc dziękuje z góry

 

O to cały kod i nie patrzcie na resztę kodu patrzcie tylko na button1 timer1 i progressbar1

 

Public Class Form1

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        MsgBox("Jakaś Ranga Nie Istnieje Na Serverze Nie Bój Sie Zostanie Ta Ranga Automatycznie Stworzona", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MsgBox("Diamenty", MsgBoxStyle.DefaultButton1, "Diax")

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MsgBox("Ranga", MsgBoxStyle.DefaultButton1, "Ranga")

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        MsgBox("UnBAN Odbanowanie Na Wybranym Serverze", MsgBoxStyle.DefaultButton1, "UnBAN")

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        MsgBox("OP/Operator Z Permissions", MsgBoxStyle.DefaultButton1, "OP")

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
        MsgBox("IP/Adres Servera ", MsgBoxStyle.Information, "IP")

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
        MsgBox("NICK/Nazwa w Minecraft", MsgBoxStyle.Information, "Name")

    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
        MsgBox("Zrób Narpiew To A Potem Kolejne ", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
        MsgBox("Zrób Tera To", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        TextBox2.Enabled = True
        Label2.Enabled = True
        Label5.Enabled = True

    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButton1.Select()

    End Sub

    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
        MsgBox("Domyślnie 0 Diamentów ", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        ProgressBar1.Enabled = True
        Button1.Enabled = True

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(1)
        Me.Text = "Ładowanie - " & ProgressBar1.Value & "%"
        Label7.Text = ProgressBar1.Value & "% Ładowania"
        If ProgressBar1.Value = 100 Then
           (TU KOD Na Usuniecie Folderu )
            Timer1.Stop()
            MsgBox("Zakończono Proces", MsgBoxStyle.MsgBoxSetForeground, "Sukces")
            MsgBox("Zakończyć Działanie Programu ?", MsgBoxStyle.Information, "Zamykanie Programu")
            Me.Close()

        End If
    End Sub
End Class
 

Opublikowano

Powinno działać:

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")

Opublikowano

Możesz mnie tego poduczyć powiedz dlaczego powinno to działać i powiec co robi kazde słowo kazy kod w tym kodzie System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")


Co odpowiada za co - System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")


Dam like


Możesz pomuc mam jakieś błędy i nie wiem co zrobić  - Error    1    'SpecialFolder' is not declared. It may be inaccessible due to its protection level. - Error  2  'GetFolderPath' is not declared. It may be inaccessible due to its protection level.


 

Opublikowano

Możesz pomuc mam jakieś błędy i nie wiem co zrobić  - Error    1    'SpecialFolder' is not declared. It may be inaccessible due to its protection level. - Error  2  'GetFolderPath' is not declared. It may be inaccessible due to its protection level.


 


nadal nie czaje Możesz pomuc mam jakieś błędy i nie wiem co zrobić  - Error    1    'SpecialFolder' is not declared. It may be inaccessible due to its protection level. - Error  2  'GetFolderPath' is not declared. It may be inaccessible due to its protection level.


Podaj mi taki kod który będzie działał

Opublikowano

dodaj na samej górze importsy:

 

Imports System.Environment
Imports System.IO
Opublikowano

jest problem Program sie ładuje do 99 % i wyskakuje Jakiś błąd Że katalog nie jest pusty jak to naprawić bo ten katalog ma być wypełniony i musi

Opublikowano

to zrób kasowanie w ten sposób:

Dim folder As String = GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft"
For Each foundFile As String In My.Computer.FileSystem.GetFiles(folder, "*.*")
My.Computer.FileSystem.DeleteFile(foundFile, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")
Next

Kod wzięty z: 

http://social.msdn.microsoft.com/Forums/vstudio/en-US/47e26ee3-2564-46ae-8b06-6db1b97d3bba/vbnet-delete-all-files-in-a-folder
Opublikowano

Gdzie Ten Kod wkleić Do Kodu Poniżej

Dim folder As String = GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft"
For Each foundFile As String In My.Computer.FileSystem.GetFiles(folder, "*.*")
My.Computer.FileSystem.DeleteFile(foundFile, FileIO.UIOption.AllDialogs, FileIO.RecycleOption.DeletePermanently)
System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")
Next

  Kod Poniżej

Imports System.Environment
Imports System.IO
Public Class Form1

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        MsgBox("Jakaś Ranga Nie Istnieje Na Serverze Nie Bój Sie Zostanie Ta Ranga Automatycznie Stworzona", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MsgBox("Diamenty", MsgBoxStyle.DefaultButton1, "Diax")

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MsgBox("Ranga", MsgBoxStyle.DefaultButton1, "Ranga")

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        MsgBox("UnBAN Odbanowanie Na Wybranym Serverze", MsgBoxStyle.DefaultButton1, "UnBAN")

    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        MsgBox("OP/Operator Z Permissions", MsgBoxStyle.DefaultButton1, "OP")

    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
        MsgBox("IP/Adres Servera ", MsgBoxStyle.Information, "IP")

    End Sub

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
        MsgBox("NICK/Nazwa w Minecraft", MsgBoxStyle.Information, "Name")

    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
        MsgBox("Zrób Narpiew To A Potem Kolejne ", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
        MsgBox("Zrób Tera To", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        TextBox2.Enabled = True
        Label2.Enabled = True
        Label5.Enabled = True

    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButton1.Select()

    End Sub

    Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
        MsgBox("Domyślnie 0 Diamentów ", MsgBoxStyle.Information, "INFO")

    End Sub

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
        ProgressBar1.Enabled = True
        Button1.Enabled = True

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ProgressBar1.Increment(1)
        Me.Text = "Ładowanie - " & ProgressBar1.Value & "%"
        Label7.Text = ProgressBar1.Value & "% Ładowania"
        If ProgressBar1.Value = 100 Then
            System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")
            Timer1.Stop()
            MsgBox("Zakończono Proces", MsgBoxStyle.MsgBoxSetForeground, "Sukces")
            MsgBox("Zakończyć Działanie Programu ?", MsgBoxStyle.Information, "Zamykanie Programu")
            Me.Close()

        End If
    End Sub
End Class
Opublikowano

zamiast tegO; System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")

Opublikowano

Powinno działać:

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft")

Jak by dodał true jako 2 parametr to by poszlo czyli

 

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft", true)

 

U mnie dziala ;)

Opublikowano

Mam Pytanie A jak edytować Ten KOD

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft", True)

żeby Ten Kod działał na inny folder i przy okazji Żeby działał w innej ścieżce

Opublikowano

Mam Pytanie A jak edytować Ten KOD

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft", True)
żeby Ten Kod działał na inny folder i przy okazji Żeby działał w innej ścieżce
To napisz jaki folder ma kasowac :)
Opublikowano

ale ja napisałem do przykładu bo chce umieć sam to zrobić i chce wiedzieć jak przerobić ten kod na inny folder ktoś mi napisze krótki opis naukowy

Opublikowano

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft", True)

To tak

System -system

IO - input output czyli wejscie wyjscie

Directory - folder

Delete - usun

 

Czyli system wejscia i wyjscia ma usunac folder :)

 

W nawiasie parametry

Getfolderpath zyskuje sciezke do w tym wypadku folderu specialnego jakim jest appdata i dodajesz do tego dalszy ciag czyli '\.minecraft'

Drugi parametr to true aby usuwalo pelen folder

 

Nwm jak to wytlumaczyc poprostu trzeba to zrozumiec :p

Opublikowano

1. a jakie foldery nie są specjalne

2. możesz mi dać końcówki te jak jest kod SpecialFolder.ApplicationData to ta końcówka .ApplicationData  podaj liste

3. naprzyklad : mam taki kod System.IO.Directory.Delete(GetFolderPath(SpecialFolder.ApplicationData) & "\.minecraft", True)  i co tu zmienić żeby usuwał inny folder nazwa folderu naprzyklad : elo i ten folder naprzyklad sie znajduje na pulpicie ?

Opublikowano

@up foldery specjalne to takie, do którcyh sam system ma w sobie zrobione skróty np: %appdata%, %windir%, %userprofile% itd.

 

Lista możliwych do wykorzystania:

http://en.wikipedia.org/wiki/Special_folder

Gdy chcesz kasowac folder elo z pulpitu:

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.DesktopDirectory) & "\elo", True)

Lub:

System.IO.Directory.Delete(GetFolderPath(SpecialFolder.Desktop) & "\elo", True)
  • 11 miesięcy temu...
Opublikowano

dzięki za pomoc , pisze to teraz bo zapomniałem napisać - trochę czasu minęło i teraz trochę potrafię (potrafię większość z pamięci) 

Zarchiwizowany

Ten temat przebywa obecnie w archiwum. Dodawanie nowych odpowiedzi zostało zablokowane.

×
×
  • Dodaj nową pozycję...