BBjClientFileSystem::getClientFile

Description

In BBj 7.0 and higher, this method returns a BBjClientFile that represents a specific file on the remote computer.

Syntax

Return Value

Method

BBjClientFile

getClientFile(BBjClientFile parentDir!, string filename$)

BBjClientFile

getClientFile(string absoluteName$)

Parameters

Variable

Description

parentDir!

The parent directory of the desired file (ignored in BUI).

filename$

The name of the desired file, relative to the parent directory.

absoluteName$

The absolute file name of the desired file.

Return Value

Returns a BBjClientFile that represents the specified file.

Remarks

Neither the returned BBjClientFile nor its parent need exist. Use the BBjClientFile::exists() method to determine whether a file exists.

BUI logo

In the BUI client, both filename$ and absoluteName$ are simple names, not complete paths, and parentDir! , if specified, is ignored. The specified filename is used as a key to a collection of user-selected files on the web server. Example 1 demonstrates a complete end-to-end cycle to copy a selected file from the client, then copy a selected file to the client; it shows that files copied from the user's machine must first be directly chosen by the user. See BUI: Interacting with client files for a discussion of the BUI BBjClientFile.

Example 1

rem ' clientfile.txt
tc! = bbjapi().getThinClient()
fs! = tc!.getClientFileSystem()
i = msgbox("Test client fileopen + copy file from client to server")
clientfile$ = fileopen("Pick a client file","","","",mode="client")
i = msgbox(clientfile$,0,"Selected client file")
if pos("::"=clientfile$) then goto eoj
cf! = fs!.getClientFile(clientfile$)
i = msgbox("Copy "+clientfile$+" to the server")
serverfile$ = cf!.copyFromClient()
serverfile = unt
open (serverfile)serverfile$
serverfile$ = fid(serverfile)(9)
bytes = dec(fin(serverfile)(1,4))
close (serverfile)
i = msgbox("Copied client file "+clientfile$+" to server file "+serverfile$+" ("+str(bytes)+" bytes)",0,"Copied from client to server")
i = msgbox("Test server fileopen + copy file from server to client")
serverfile$ = fileopen("Pick a server file","","","")
i = msgbox(serverfile$,0,"Selected server file")
if pos("::"=serverfile$) then goto eoj
clientfile! = new java.io.File(serverfile$)
clientfile$ = clientfile!.getName()
clientfile$ = filesave("Save to client","",clientfile$,"",mode="client")
if pos("::"=clientfile$) then goto eoj
i = msgbox("Copy server file "+serverfile$+" to client file "+clientfile$)
cf! = fs!.getClientFile(clientfile$)
cf!.copyToClient(serverfile$)
i = msgbox("Copied server file "+serverfile$+" to client file "+clientfile$,0,"Copied from server to client")
eoj:
release

Example 2

See Also

BBjAPI

BBjThinClient

BBjClientFileSystem

BBjClientFile

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.