StandardFileDialog.FileName 属性 |
命名空间: VO
1METHOD OpenDB() CLASS StandardShellWindow 2 LOCAL oOpenDialog AS OpenDialog 3 LOCAL uFileName AS USUAL 4 LOCAL aoFileSpecs := {} AS ARRAY 5 LOCAL lDone := .F. AS LOGIC 6 LOCAL oDB AS Dbserver 7 8 DO WHILE !lDone 9 oOpenDialog:=OpenDialog{SELF} 10 oOpenDialog:Caption:="Open DBF and Index" 11 oOpenDialog:SetFilter ({"CUST*.*","ORD*.*","DET*.*"}, {"Customers", "Orders", "Details"}) 12 oOpenDialog:SetStyle(OFN_ALLOWMULTISELECT + OFN_HIDEREADONLY) 13 oOpenDialog:InitialDirectory := "C:\CAVO2x\SAMPLES\GSTUTOR" 14 oOpenDialog:Show() 15 16 uFileName := oOpenDialog:FileName 17 18 IF IsArray(uFileName) .AND. ALen(uFileName) > 2 19 (TextBox{SELF,"File Selection Error",; 20 "Too many files selected"+CRLF+; 21 "Please select one DBF and one index"}):Show() 22 ELSE 23 lDone := .T. 24 ENDIF 25 ENDDO 26 27 // Open the selected DBF and index file 28 uFileName := oOpenDialog:FileName 29 30 IF IsArray(uFileName) // DBF and Index selected ? 31 AEval(uFileName,{ | cFileName | AADD( ; 32 aoFileSpecs, FileSpec{cFileName} ) } ) 33 34 IF aoFileSpecs[1]:Extension != ".DBF" 35 aoFileSpecs[1]:= ArraySwap(aoFileSpecs, 2, aoFileSpecs[1]) 36 ENDIF 37 38 RDDSetDefault("DBF"+SUBSTR(aoFileSpecs[2]:Extension, 2, 3) ) 39 oDB := DBServer{aoFileSpecs[1]} 40 oDB:SetIndex(aoFileSpecs[2]) 41 42 ELSEIF LOGIC(_CAST, uFileName) // Anything selected at all? 43 44 AADD(aoFileSpecs,FileSpec{uFileName}) 45 oDB := DBServer{aoFileSpecs[1]} 46 ENDIF 47 RETURN oDB