Click here to Skip to main content
15,916,693 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralInterfacing with 3rd party applications Pin
grazza20-Aug-03 11:09
grazza20-Aug-03 11:09 
GeneralDatabase on PocketPC Pin
Richard Jones20-Aug-03 8:48
Richard Jones20-Aug-03 8:48 
GeneralExcel to Comma Delimited Text File Pin
hollywood_vb20-Aug-03 5:03
hollywood_vb20-Aug-03 5:03 
Questionshortcut key for image button? Pin
dungti19-Aug-03 20:22
dungti19-Aug-03 20:22 
AnswerRe: shortcut key for image button? Pin
Csharp™20-Aug-03 1:26
Csharp™20-Aug-03 1:26 
GeneralVB application on the intranet Pin
funstone19-Aug-03 15:45
funstone19-Aug-03 15:45 
GeneralVB.Net Windows Service problem Pin
Gösta Eriksson19-Aug-03 2:05
Gösta Eriksson19-Aug-03 2:05 
QuestionFileSystemObject, Trace and Compiled Difference? Pin
Paul Riley18-Aug-03 13:21
Paul Riley18-Aug-03 13:21 
Okay, I admit defeat, I've been looking at this for a long time and I can't figure it out. Look at the following code (VB6):
Private Sub CmdCopy(ByVal sourceFileOrDir As String, _
                    ByVal targetDir As String)

    Dim fso As New FileSystemObject
    
    If fso.FileExists(sourceFileOrDir) Then
        ' Copy source file to target folder
        fso.CopyFile sourceFileOrDir, fso.BuildPath(targetDir, fso.GetFileName(sourceFileOrDir)), True
    ElseIf fso.FolderExists(sourceFileOrDir) Then
        ' Copy source directory contents to target folder
        CopyContents sourceFileOrDir, targetDir
    Else
        MsgBox sourceFileOrDir & vbCrLf & targetDir
    End If
    
End Sub
The sourceFileOrDir argument has already been validated, so the file/folder must exist. When I run this in trace mode, it runs fine, each file or folder contents are copied as requested.

But when I run it compiled, the folder contents copy fine but when sourceFileOrDir is a file, the fso.FileExists function returns false and the message box is displayed.

To be more specific, if I set a breakpoint on the first "If" then it works fine, but if I set a breakpoint on the MsgBox line then it doesn't.

Can anyone explain this bizarity for me? Is there a workaround?

Paul
AnswerRe: FileSystemObject, Trace and Compiled Difference? Pin
Hesham Amin18-Aug-03 21:31
Hesham Amin18-Aug-03 21:31 
GeneralRe: FileSystemObject, Trace and Compiled Difference? Pin
Paul Riley18-Aug-03 23:59
Paul Riley18-Aug-03 23:59 
GeneralRe: FileSystemObject, Trace and Compiled Difference? Pin
Hesham Amin19-Aug-03 0:12
Hesham Amin19-Aug-03 0:12 
GeneralRe: FileSystemObject, Trace and Compiled Difference? Pin
Paul Riley19-Aug-03 0:21
Paul Riley19-Aug-03 0:21 
GeneralWord Automation Pin
Emile Jacobs18-Aug-03 6:08
Emile Jacobs18-Aug-03 6:08 
GeneralRe: Word Automation Pin
Nick Seng18-Aug-03 16:16
Nick Seng18-Aug-03 16:16 
GeneralReal-time plots in VB Pin
blaze197818-Aug-03 5:11
blaze197818-Aug-03 5:11 
GeneralRe: Real-time plots in VB Pin
Anonymous27-Aug-03 11:52
Anonymous27-Aug-03 11:52 
GeneralVB6 Pin
totig18-Aug-03 4:34
totig18-Aug-03 4:34 
GeneralRe: VB6 Pin
Nick Seng18-Aug-03 16:05
Nick Seng18-Aug-03 16:05 
GeneralPrinting by VB.NET Pin
rain117818-Aug-03 1:00
rain117818-Aug-03 1:00 
QuestionHow can i send keystrokes to a window in created by another process Pin
Quatl17-Aug-03 17:40
Quatl17-Aug-03 17:40 
AnswerRe: How can i send keystrokes to a window in created by another process Pin
Martin Cross24-Aug-03 23:53
Martin Cross24-Aug-03 23:53 
Generalreading RTF message Body, outlook automation Pin
pnpfriend13-Aug-03 5:00
pnpfriend13-Aug-03 5:00 
QuestionCreating A Bitmap? Pin
GrindAZ12-Aug-03 9:48
GrindAZ12-Aug-03 9:48 
GeneralBuilding a report viewer for Access Pin
sagmam10-Aug-03 22:07
sagmam10-Aug-03 22:07 
GeneralRe: Building a report viewer for Access Pin
mikasa27-Aug-03 2:57
mikasa27-Aug-03 2:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.