VB6通用对话框控制文件打开在某些Windows 7 PC上没有提供正确的文件夹

时间:2014-08-22 09:27:10

标签: windows vb6

我的VB6应用程序使用Common Dialog Control for File Open等。 这些代码在数百台PC上运行良好。

但我有一个客户,其中File Open命令显示错误的文件夹。 他正在运行Windows 7。

这是我的代码的摘录:

Private Sub mnuFileItem_Click(Index As Integer)
    CommonDialog1.FileName = "" 'workaround for problem with .InitDir (20051010)
    CommonDialog1.InitDir = strDataPath
    ' Set filters
    CommonDialog1.Filter = ApplicationName & " Files (*" & PreProcessorFileExtension & ")|*" & PreProcessorFileExtension        
    ' Set dialog box so error occurs if the dialog box is cancelled '20020418
    CommonDialog1.CancelError = True
    Select Case Index   ' Check index value of selected menu item.
        Case 0  ' If index = 0, the user chose "New"            
            'code omitted here              
        Case 1  ' If index = 1, the user chose "Open..."            
            ' display the File Open dialog
            CommonDialog1.Action = 1                          
            FileName = CommonDialog1.FileName
            OpenCLSFile             
        Case 2 To 3  'If index = 2,  "Save..."  = 3, "Save As..."           
            'code omitted here          
    End Select
End Sub

通常,用于定义CommonDialog1.InitDir,strDataPath的变量设置为:

C:\ Users \ Public \ Documents \ Mincad Systems \ CIRCLY5 \ data

但对于遇到此问题的用户,将显示“文件打开”对话框:

C:\ Users \ Public \ Documents \ Mincad Systems \ CIRCLY6 \ data

我有来自用户的日志,确认CommonDialog1.InitDir =

C:\ Users \ Public \ Documents \ Mincad Systems \ CIRCLY5 \ data

在Sub mnuFileItem_Click中的每个语句之前。

用户也在使用我的应用程序的vb.net版本。 在该应用程序中,“文件打开”对话框使用文件夹:

C:\ Users \ Public \ Documents \ Mincad Systems \ CIRCLY6 \ data

vb.net应用程序是否有某种方法可以重置VB6应用程序使用的Common Dialog Control属性的某些属性? 我尝试使用Win32 API版本替换VB6通用对话框文件打开 - 但我的用户仍然遇到同样的问题。

此致 利

1 个答案:

答案 0 :(得分:0)

我知道这篇文章很老,但也许这会对某人有所帮助。我在我的案例中发现,如果您在该PC上不存在设置Initdir的目录,则使用当前目录。

相关问题