BBjClientFile

Creation Path


BBjAPI

|

+--BBjThinClient

|

+--BBjClientFileSystem

|

+--BBjClientFile

 

Description

The BBjClientFile object provides developers methods to manipulate a specific client-side file.

Creation

The BBjClientFile object is created through the following BBjClientFileSystem object methods:

Return Value

Method

BBjClientFile

getClientFile(BBjClientFile parentDir!, string fileName)

BBjClientFile

getClientFile(string absoluteName)

Methods of BBjClientFile

Return Value

Method

boolean

canExecute()

boolean

canRead()

boolean

canWrite()

string

copyFromClient()

string

copyFromClient(string p_serverFile)

void

copyToClient(string serverFileName)

boolean

createNewFile()

boolean

delete()

boolean

exists()

BBjClientFile

getCanonicalFile()

string

getContents()

string

getName()

BBjClientFile

getParent()

string

getPath()

boolean

isDirectory()

boolean

isFile()

boolean

isHidden()

long

lastModified()

BBjVector

listFiles()

boolean

mkdir()

boolean

mkdirs()

boolean

renameTo(BBjClientFile newName!)

void

setContents(string contents)

boolean

setExecutable(boolean p_executable)

void

setLastModified(long time)

boolean

setReadable(boolean p_readable)

void

setReadOnly()

boolean

setWritable(boolean p_writable)

long

size()

Constants

None.

Remarks

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

BBj Object Syntax

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



______________________________________________________________________________________

Copyright BASIS International Ltd. BBj®, Visual PRO/5®, PRO/5®, and BBx® are registered trademarks.