You are not logged in.

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

1

Wednesday, January 23rd 2013, 12:31pm

can't copy my directory

Hi again i am trying to have a button in my api that takes back up.
so i am doing something like this...

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Public Sub Form_ToolBarClick(ToolBarItem As VB#IToolBarItem)
  
   If ToolBarItem.ControlID = "backup" Then	
   intResponse2 = MsgBox("Θέλετε να δημιουργηθεί αντίγραφο ασφαλείας;", vbYesNo + vbQuestion,"Back Up")
   
   If intResponse2 = vbYes Then  
   myfolderdate = Day(dd) &"."& Month(mm) &"."& Year(yyyy) 
   'MsgBox myfolderdate	
   MkDir "C:\back_up"& myfolderdate 
   
   from_folder =  "C:\xampp\mysql\data\my_api_2012"
   to_folder = "C:\back_up"& myfolderdate 
 
   
   FileCopy from_folder,To_folder 
   

   End If
   End If
   
End Sub


BUT always having

"can't copy file directory"

Do you have any idea why is this happening?

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

2

Wednesday, January 23rd 2013, 4:44pm

RE: can't copy my directory

Do you have any idea why is this happening?


Because - as the name said - FileCopy copies files and not directories. :)

To copy a directoy is a little more difficult. An implementation for it, currently not exist.
You have to read the directory, file by file and subduirectory by subdirectory.
You have to copy every single file. And if there is a subdirectory, you have to read the name of it and create it on the new place. Then doing the same with the subvdirectory like with the directory before.

Greatings
theuserbl

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

3

Wednesday, January 23rd 2013, 8:10pm

Yes file/file works fine.
Because i need to take a back up of my mysql database could you please inform me which files or directories are most important?
I took a back up of -- >c:\xampp\mysql\data\mydb\...
is that ok or need more?

Thanks

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

4

Wednesday, January 23rd 2013, 9:08pm

Hey there,

with H2 all it takes is one SQL command

Jabaco Source

1
BACKUP TO 'backup.zip'


for a zip archive or

Jabaco Source

1
SCRIPT TO 'C:\myScript.sql'


very elegant!

With MySql you will have to look at mysqldump
http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html

But it might be enough to backup the folder your database is located at. And thats simply the folder you set your database up in!!

Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

5

Thursday, January 24th 2013, 11:49am

Hi Dani!

Because i am a little bit confused do you thing that i am ok taking back up my folder that mention above or have to make the dump?

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

6

Thursday, January 24th 2013, 4:15pm

Because FileCopy copies only files, here a first implementation of DirCopy, which copies complete directories:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Public Static Function DirCopy(Source As String, Destination As String) As Boolean
  Dim SourceFile As java#io#File = New File(Source)
  Dim DestinationFile As java#io#File = New File(Destination)
  DirCopy = True
  If (NOT SourceFile.exists) Then
    MsgBox "Source-directory " & Chr(34) & Source & Chr(34) & " don't exists"
    DirCopy = False
    Exit Function
  Elseif (NOT SourceFile.isDirectory) Then
    MsgBox "Source-directory " & Chr(34) & Source & Chr(34) & " not a directory"
    DirCopy = False
    Exit Function
  Else
    If (NOT DestinationFile.exists) Then
      MkDir Destination
    End If
    If (NOT DestinationFile.isDirectory) Then
      MsgBox "Destination-directory " & Chr(34) & Destination & Chr(34) & " not a directory"
      DirCopy = False
      Exit Function
    End If
  End If
  
  Dim childFolders() As File
  childFolders() = SourceFile.listFiles()

  Dim item As File
  For Each item In childFolders
    If item.isFile Then
      FileCopy (Source & System.getProperty("file.separator") & item.getName , Destination & System.getProperty("file.separator") & item.getName)
    ElseIf item.isDirectory Then
      DirCopy (Source & System.getProperty("file.separator") & item.getName , Destination & System.getProperty("file.separator") & item.getName)    
    End If
  Next
End Function


If I have more time and if I haven't forgotten it then, I will include it in the JabacoFramework.

Sadly the DirCopy works slow.

Currently I haven't checked, if the Destination-directory is a subdirectoy of the Source-directory. If so, then it copies endless.
So be careful, that the Source and the Destination are two complete different directories and not the one is included in the other.

Greatings
theuserbl

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

7

Thursday, January 24th 2013, 4:58pm

Hey there,

:thumbsup:

just to fill the gaps...

http://www.vbarchiv.net/tipps/details.php?id=909


Dani

fomaxrge

Trainee

  • "fomaxrge" started this thread

Posts: 88

Date of registration: Aug 14th 2012

  • Send private message

8

Thursday, January 24th 2013, 9:01pm

:thumbsup: It works perfect.
Thank you!!!

Is there a way to have a msgbox inform me that the copy FINESSED?

theuserbl

Intermediate

Posts: 436

Date of registration: Dec 20th 2008

  • Send private message

9

Monday, January 28th 2013, 12:51pm

Updated framework
[ Jabaco-rev105.jar ]
theuserbl

Rate this thread
WoltLab Burning Board