Forum » Programiranje » [VB] brisanje polne mape
[VB] brisanje polne mape
jishiri ::
zdravo
malo sem se igral in bi naredil program ki bi brisal premikal koperal datoteke in mape... sedaj se mi je ustavilo pri brisanju polne mape.. (prazne lepo brise)
hvala za pomoce in nasvete...
LP
malo sem se igral in bi naredil program ki bi brisal premikal koperal datoteke in mape... sedaj se mi je ustavilo pri brisanju polne mape.. (prazne lepo brise)
Private Sub Button2_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button2.Click For Each Item As IO.FileInfo In _ Me.CheckedListBox2.CheckedItems Try If Item.Exists = True Then Item.Delete() Catch : End Try Next Item For Each Item As IO.DirectoryInfo In Me.CheckedListBox1.CheckedItems Try If Item.Exists = True Then Item.Delete() Catch : End Try Next Item end sub
hvala za pomoce in nasvete...
LP
- spremenil: Primoz ()
*ziga* ::
Public Function KillFolder(ByVal FullPath As String) _ As Boolean '****************************************** 'PURPOSE: DELETES A FOLDER, INCLUDING ALL SUB- ' DIRECTORIES, FILES, REGARDLESS OF THEIR ' ATTRIBUTES 'PARAMETER: FullPath = FullPath of Folder to Delete 'RETURNS: True is successful, false otherwise 'REQUIRES: 'VB6 'Reference to Microsoft Scripting Runtime 'Caution in use for obvious reasons 'EXAMPLE: 'KillFolder("D:\MyOldFiles") '****************************************** On Error Resume Next Dim oFso As New Scripting.FileSystemObject 'deletefolder method does not like the "\" 'at end of fullpath If Right(FullPath, 1) = "\" Then FullPath = _ Left(FullPath, Len(FullPath) - 1) If oFso.FolderExists(FullPath) Then 'Setting the 2nd parameter to true 'forces deletion of read-only files oFso.DeleteFolder FullPath, True KillFolder = Err.Number = 0 And _ oFso.FolderExists(FullPath) = False End If End Function Private Sub Form_Load() KillFolder "C:\test" End Sub
To bi moralo delat.Drugic poisci malo po netu.
Zgodovina sprememb…
- spremenil: Primoz ()
BigWhale ::
Pobrisat še moreš datoteke in mape v tej mapi. Uporabiš rekurzijo
Ja, sam glej, da ti ne bo stacka zmanjkal!!!
jishiri ::
hvala za te vrstice... sem stvar resil na podoben nacin, le malo se razlikuje, da brise v ciklih, glede na kolicino faila v sami mapi in ostalih podmapah... da ne bi prihajalo do neodzivnosti programa...
hvala za pomoc...
LP, JM
hvala za pomoc...
LP, JM
Zgodovina sprememb…
- spremenilo: jishiri ()
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Visual BasicOddelek: Programiranje | 3432 (2458) | cekr |
» | [VB] polepšanje kodeOddelek: Programiranje | 746 (652) | korenje3 |
» | [VB] Komunikacija s serijskimi napravamiOddelek: Programiranje | 2305 (1579) | mNeRo |
» | VB.net MDI in formi splošnoOddelek: Programiranje | 1612 (1555) | strel |
» | vkljucevanje txt datoteke v ...Oddelek: Programiranje | 1580 (1356) | webblod |