Click or drag to resize

StandardFileDialog.FileName Property

X#
A string representing the name of the file which the user selected. If the user cancels, the file name is NULL_STRING.

Namespace:  VO
Assembly:  VOGUIClasses (in VOGUIClasses.dll) Version: 2.19
Syntax
 VIRTUAL PROPERTY FileName AS USUAL GET 
Request Example View Source

Property Value

Type: Usual
A string representing the name of the file which the user selected. If the user cancels, the file name is NULL_STRING.
Examples
This example displays an OpenFile dialog with a filter which is set to display only DBFs and index files. Multiple file selection enables a user to select a DBF and an index. A DBServer object for the selected file(s) is created and returned to the caller.
X#
 1METHOD OpenDB() CLASS StandardShellWindow
 2LOCAL oOpenDialog   AS OpenDialog
 3LOCAL uFileName   AS USUAL
 4LOCAL aoFileSpecs  := {}  AS ARRAY
 5LOCAL lDone  := .F.  AS LOGIC
 6LOCAL oDB   AS Dbserver
 7DO WHILE !lDone
 8oOpenDialog:=OpenDialog{SELF}
 9oOpenDialog:Caption:="Open DBF and Index"
10oOpenDialog:SetFilter ({"CUST*.*","ORD*.*","DET*.*"},;
11{"Customers", "Orders", "Details"})
12oOpenDialog:SetStyle(OFN_ALLOWMULTISELECT + OFN_HIDEREADONLY)
13oOpenDialog:InitialDirectory := "C:\CAVO2x\SAMPLES\GSTUTOR"
14oOpenDialog:Show()
15uFileName := oOpenDialog:FileName
16IF IsArray(uFileName) .AND. ALen(uFileName) > 2
17(TextBox{SELF,"File Selection Error",;
18"Too many files selected"+CRLF+;
19"Please select one DBF and one index"}):Show()
20ELSE
21lDone := .T.
22ENDIF
23ENDDO
24// Open the selected DBF and index file
25uFileName := oOpenDialog:FileName
26IF IsArray(uFileName)   // DBF and Index selected ?
27AEval(uFileName,{ | cFileName | AADD( ;
28aoFileSpecs, FileSpec{cFileName} ) } )
29IF aoFileSpecs[1]:Extension != ".DBF"
30aoFileSpecs[1]:= ArraySwap(aoFileSpecs, ;
312, aoFileSpecs[1])
32ENDIF
33RDDSetDefault("DBF"+SUBSTR(aoFileSpecs[2]:;
34Extension, 2, 3) )
35oDB := DBServer{aoFileSpecs[1]}
36oDB:SetIndex(aoFileSpecs[2])
37ELSEIF LOGIC(_CAST, uFileName)   // Anything selected at all?
38AADD(aoFileSpecs,FileSpec{uFileName})
39oDB := DBServer{aoFileSpecs[1]}
40ENDIF
41RETURN oDB
See Also