' 25 february 2012 Extended Copy : Copyrighted by J. van Zijl aka Slowdown ' Copy files with or without the full path. ' Q7Basic for Windows? 7/Vista/XP BETA 22-December-2011 (32 bit) ' NOT tested on Linux/OSX. ' You can find me on, ' http://www.q7basic.org/forum/index.php and ' http://www.kbasic.com/forum/index.php ' j.vanzijl@quicknet.nl ' code donated to public domain. Outlet pushButtonDestination As QPushButton Outlet pushButtonSource As QPushButton Outlet pushButtonCopyFile As QPushButton Outlet pushButtonCopyFilePathFile As QPushButton Dim SFile As String Dim DDir As String Signal on_pushButtonDestination_clicked(Checked As Boolean) DDir = OpenFileDialog.GetDirectory2("Select destination directory", "/") End Signal Signal on_pushButtonSource_clicked(Checked As Boolean) SFile = OpenFileDialog.GetFile2("Select file to copy", "/", "") End Signal Signal on_pushButtonCopyFile_clicked(Checked As Boolean) Dim IsOk As Boolean IsOk = CopyFile(SFile, DDir & "/" & FileName(SFile), False, True) End Signal Signal on_pushButtonCopyFilePathFile_clicked(Checked As Boolean) Dim IsOk As Boolean IsOk = CopyFile(SFile, DDir, True, True) End Signal Function StripDrive(S As String) As String If OS.IsWindows() = True Then Return Right(S, Len(S) - 2) End If End Function Function CopyFile(sf As String, dp As String, fp As Boolean, ow As Boolean) As Boolean 'sf = source file path included. 'dp = destination path. 'fp = true when full path must be copied. 'ow = true when destination file will be overwritten if pressent. 'returns true when the copy is succesfull. Dim IsOk As Boolean If fp = False Then IsOk = File.Copy(sf, dp, ow) Else If Right(dp, 1) = "/" Then dp = Left(dp, Len(dp) - 1) End If IsOk = Dir.RecursiveCreate(dp & StripDrive(FilePath(sf))) IsOk = File.Copy(sf, dp & StripDrive(FilePath(sf)), ow) End If End Function