|
-
Jul 5th, 2002, 03:20 PM
#1
Thread Starter
Lively Member
FileCopy (Resolved - great solution provided) problems
Good afternoon,
I was using a FileCopy function with great success, except that the screen made it appear that the program crashed... I tried adding a form that would appear and let the user know to wait, however that form also just stacked itself ontop and was actually transparent except the title bar. I have tried hourglasses also - they never appeared.
I am using commondialogues to obtain the file information.
I was researching solutions earlier on the forums and tried using the Windows Copy File animation but am obviously missing something. I edited from an example and obviously edited out something important!!
If anyone wants to take a crack at reading this to see if you have any suggestions please feel free!!! Or if you have any other suggestions on what to do about the "crashed" appearance on the screen that would be good too!!
I am copying a file that is identified through an Open dialogue, and the destination is obtained through a SaveAs dialogue.
I also think that I need the .avi on the form but when I tried that it crashed VB (not just my program!).
I am very new so I may also be missing references or something silly like that! I did reference the lib from the code (shell32.dll)
Thanks,
Mary
*********** My attempt at the code VB 6 **************
Option Explicit
Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As String
SourceFile As String
DestinationFile As String
End Type
Private Enum FO_OPS
FO_MOVE = &H1
FO_COPY = &H2
FO_DELETE = &H3
FO_RENAME = &H4
End Enum
Private Enum FO_FLAGS
FOF_CREATEPROGRESSDLG = &H0
FOF_NOCONFIRMMKDIR = &H200
End Enum
Private Declare Function SHFileOperation Lib "Shell32.dll" _
Alias "SHFileOperationA" (lpFileOp As Any) As Long
Private Sub cmdCancel_Click()
'unload form and return to main screen
Unload Me
FrmMain.Show
End Sub
Private Sub cmdExit_Click()
'Close and exit program
End
End Sub
Private Sub cmdFindShellDB_Click()
'Locate SRT Shell Database
On Error GoTo ErrHandler
diaFindShell.ShowOpen
txtShellDBName.Text = diaFindShell.FileTitle
ErrHandler:
'MsgBox "Unexplained error, please try again"
Exit Sub
End Sub
Private Sub cmdSaveSurveyDB_Click()
'Save Shell as new survey database
'On Error GoTo ErrHandler
diaSaveSurveyDB.FileName = txtDatasetName.Text & ".mdb"
diaSaveSurveyDB.ShowSave
txtSurveyDBName.Text = diaSaveSurveyDB.FileTitle
'SurveyDB = diaSaveSurveyDB.FileName
'copy shell file to create survey specific database and show
'Windows copy progress dialogue
Dim fileop As SHFILEOPSTRUCT
Dim lRet As Long
Dim SourceFile, DestinationFile
DestinationFile = diaSaveSurveyDB.FileName 'I have also tried
'with 2 vbNull added
SourceFile = diaFindShell.FileName 'I have also tried with
'2 vbNull added
With fileop
.hwnd = Me.hwnd
.SourceFile = SourceFile
.DestinationFile = DestinationFile
.wFunc = FO_COPY
.fFlags = FOF_CREATEPROGRESSDLG
'FileCopy SourceFile, DestinationFile
End With
lRet = SHFileOperation(fileop)
cmdNext.Enabled = True
'ErrHandler:
'MsgBox "Unexplained error, please try again"
' Exit Sub
End Sub
Private Sub txtDatasetName_LostFocus()
'ensure that user only entered an 8-character name and format for uppercase -- this name will include letters and numbers
' maybe add naming convention rules to help files later
If Len(txtDatasetName.Text) <> 8 Then
MsgBox "The dataset name should be 8 characters long
and should match the name of your final SAS dataset. " _
& vbCrLf & "Please try again."
txtDatasetName.SetFocus
Exit Sub
End If
End Sub
Last edited by A441OTA; Jul 9th, 2002 at 11:39 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|