Child pages
  • file

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
<!--
{hidden}DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.
		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURC-->SOURCE{hidden}
The File plugin provides functionality to work with files.

Main features are:
- Creating temporary files
- Reading from and writing to the filesystem
- Retrieving information on files and directories on the file system 
- Streaming files between the Smart Client and the Server (and vise versa)

When using the File plugin, it's important to take into account the differences and compatibility between different clients:
- Interacting with the file system through the plugin in a Smart Client happens client-side, so on the machine where the Smart Client is launched. On all other clients (Web, Headless & Batchprocessor), the operations are performed on the Server.
- All showXxxxDialog(...) functions interact with the user through a UI. These function can only be used in Clients that provide a UI, like the Smart and Web Client.
- The showXxxxDialog(...) functions, when used in the Web Client, have certain limitations due to being operated in a browser. Browser security (currently) limits interaction with the local file system, except for single file select operations initiated by the user clicking a button.\\ 

{table:id=|class=servoy sReturnTypes}{tr:style=height: 30px;}{th}Return Types{th}{tr}{tr}{td}{span:class=sWordList}[JSFile]{span}{td}{tr}{table}\\ 

{table:id=|class=servoy sSummery}{colgroup}{column:padding=0px|width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Server Property Summery{th}{tr}{tbody}{tr}{td}{td}{td}[#servoy.FileServerService.defaultFolder]
{td}{tr}{tbody}{table}\\ 

{table:id=|class=servoy sSummery}{colgroup}{column:padding=0px|width=80px}{column}{column}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=2}Method Summery{th}{tr}{tbody}{tr}{td}[Boolean]{td}{td}[#appendToTXTFile]\(file/fileName, text, \[encoding\])
Appends data into a text file.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#convertToJSFile]\(file)
Returns a JSFile instance corresponding to an alternative representation of a file (for example a string).{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#convertToRemoteJSFile]\(serverPath)
Returns the JSFile object of a server file, given its path (relative the default server location){td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#copyFile]\(sourceFile, destinationFile)
Copies the sourcefile to the destination file.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#copyFolder]\(sourceFolder, destinationFolder)
Copies the sourcefolder to the destination folder, recursively.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#createFile]\(targetFile)
Creates a JSFile instance.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#createFolder]\(targetFolder)
Creates a folder on disk.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#createTempFile]\(filePrefix, fileSuffix)
Creates a temporary file on disk.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#deleteFile]\(targetFile)
Removes a file from disk.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#deleteFolder]\(targetFolder, showWarning)
Deletes a folder from disk recursively.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#getDesktopFolder]\()
Returns a JSFile instance that corresponds to the Desktop folder of the currently logged in user.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]\[]{td}{td}[#getDiskList]\()
Returns an Array of JSFile instances correponding to the file system root folders.{td}{tr}{tbody}{tbody}{tr}{td}[Number]{td}{td}[#getFileSize]\(targetFile)
Returns the size of the specified file.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]\[]{td}{td}[#getFolderContents]\(targetFolder, \[fileFilter\], \[fileOption(1=files,2=dirs)\], \[visibleOption(1=visible,2=nonvisible)\], \[lockedOption(1=locked,2=nonlocked)\])
Returns an array of JSFile instances corresponding to content of the specified folder.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#getHomeDirectory]\()
Returns a JSFile instance corresponding to the home folder of the logged in used.{td}{tr}{tbody}{tbody}{tr}{td}[Date]{td}{td}[#getModificationDate]\(targetFile)
Returns the modification date of a file.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]\[]{td}{td}[#getRemoteList]\(serverFolder/serverFolderPath, \[filesOnly\])
Retrieves a list of files existing in a folder on the server side (in the path provided, relative to the default server location){td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#moveFile]\(sourceFile, destinationFile)
Moves the file from the source to the destination place.{td}{tr}{tbody}{tbody}{tr}{td}byte[]{td}{td}[#readFile]\(\[file\], \[size\])
Reads all or part of the content from a binary file.{td}{tr}{tbody}{tbody}{tr}{td}[String]{td}{td}[#readTXTFile]\(\[file\], \[charsetname\])
Read all content from a text file.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#showDirectorySelectDialog]\(\[directory suggestion\], \[dialog title text\])
Shows a directory selector dialog.{td}{tr}{tbody}{tbody}{tr}{td}[Object]{td}{td}[#showFileOpenDialog]\(\[selectionMode(0=both,1=Files,2=Dirs)\], \[startDirectory(null=default/previous)\], \[multiselect(true/false)\], \[filterarray\], \[callbackmethod\], \[dialog title text\])
Shows a file open dialog.{td}{tr}{tbody}{tbody}{tr}{td}[JSFile]{td}{td}[#showFileSaveDialog]\(\[fileName/dir suggestion\], \[dialog title text\])
Shows a file save dialog.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#streamFilesFromServer]\(file/fileName|fileArray/fileNameArray, serverFile/serverFileName|serverFileArray/serverFileNameArray, \[callbackFunction\])
Streams a file or an array of files from the server in a background task to a file (or files) on the client.{td}{tr}{tbody}{tbody}{tr}{td}void{td}{td}[#streamFilesToServer]\(file/fileName|fileArray/fileNameArray, \[serverFile/serverFileName|serverFileArray/serverFileNameArray\], \[callbackFunction\])
Streams a file or an array of files to the server in a background task \- with optional relative path(s)/(new) name(s).{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#writeFile]\(file, binary_data, \[mimeType\])
Writes data into a binary file.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#writeTXTFile]\(file, text_data, \[charsetname\], \[mimeType\])
Writes data into a text file.{td}{tr}{tbody}{tbody}{tr}{td}[Boolean]{td}{td}[#writeXMLFile]\(file, xml_data)
Writes data into an XML file.{td}{tr}{tbody}{table}\\ 

{table:id=serverProperty|class=servoy sDetail}{colgroup}{column:padding=0px|width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Server Property Details{th}{tr}{tbody:id=servoy.FileServerService.defaultFolder|class=node}{tr:id=name}{td}h6.servoy.FileServerService.defaultFolder{td}{tr}{tr:id=des}{td}Set the default folder path to save files sent by client (will default to /uploads/){td}{tr}{tr:id=sncclass=lastDetailRow}{td}{td}*Since*}{tr}{tbody}{table}\\ Replace
with version info{td}{tr
{table:id=function|class=servoy sDetail}{colgroup}{column:padding=0px|width=100%}{column}{colgroup}{tr:id=prs}{td}*Parameters*\\{tdstyle=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=appendToTXTFile|class=node}{tr:id=retname}{td}*Returns*\\h6.appendToTXTFile{td}{tr}{tr:id=seesig}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}appendToTXTFile{span}{span:id=iets|style=float: left;}\(file/fileName, text, \[encoding\]){span}{td}{tr}{tr:id=samdes}{td}*Sample*\\{div:class=sIndent}{div}{Appends data into a text file.{td}{tr}{tr:classid=lastDetailRowprs}{td}{td}{tr}{tbody}{table}\\ 

{table:id=function|class=servoy sDetail}{colgroup}{column:padding=0px|width=100%}{column}{colgroup}{tr:style=height: 30px;}{th:colspan=1}Method Details{th}{tr}{tbody:id=appendToTXTFile|class=node}{tr:id=name}{td}h6.appendToTXTFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}appendToTXTFile{span}{span:id=iets|style=float: left;}\(file/fileName, text, \[encoding\]){span*Parameters*\\file/fileName
text
\[encoding\]
{td}{tr}{tr:id=ret}{td}*Returns*\\ [Boolean]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// append some text to a text file:
	var ok = plugins.file.appendToTXTFile('myTextFile.txt', '\nMy fantastic new line of text\n');
{code}{div}{td}{tr}{tr:idclass=deslastDetailRow}{td}Appends data into a text file.{td}{tr{td}{tr}{tbody}{tbody:id=convertToJSFile|class=node}{tr:id=sncname}{td}*Since*\\ Replace with version infoh6.convertToJSFile{td}{tr}{tr:id=prssig}{td}*Parameters*\\file/fileName
text
\[encoding\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}convertToJSFile{span}{span:id=iets|style=float: left;}\(file){span}{td}{tr}{tr:id=des}{td}Returns a JSFile instance corresponding to an alternative representation of a file (for example a string).{td}{tr}{tr:id=linkprs}{td}*External linksParameters*\\{div:class=sIndent}{div}file
{td}{tr}{tr:id=ret}{td}*Returns*\\ [JSFile]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// append some text to a text file:
	var okf = plugins.file.appendToTXTFileconvertToJSFile('myTextFile"story.txt', '\nMy fantastic new line of text\n'");
if (f.canRead())
	application.output("File can be read.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=convertToJSFileconvertToRemoteJSFile|class=node}{tr:id=name}{td}h6.convertToJSFileconvertToRemoteJSFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}convertToJSFileconvertToRemoteJSFile{span}{span:id=iets|style=float: left;}\(fileserverPath){span}{td}{tr}{tr:id=des}{td}Returns athe JSFile instance corresponding to an alternative representation object of a server file, (forgiven exampleits a string).{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version infopath (relative the default server location){td}{tr}{tr:id=prs}{td}*Parameters*\\fileserverPath
{td}{tr}{tr:id=ret}{td}*Returns*\\ [JSFile]{td}{tr}{tr:id=seesam}{td}*Also seeSample*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var code:language=javascript}
var f = plugins.file.convertToJSFileconvertToRemoteJSFile("'/story.txt"');
if (f && f.canRead())
	application.output("'File can be read."');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=convertToRemoteJSFilecopyFile|class=node}{tr:id=name}{td}h6.convertToRemoteJSFilecopyFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFileBoolean]{span}{span:id=iets|style=float: left; font-weight: bold;}convertToRemoteJSFilecopyFile{span}{span:id=iets|style=float: left;}\(serverPathsourceFile, destinationFile){span}{td}{tr}{tr:id=des}{td}ReturnsCopies the JSFilesourcefile objectto ofthe a serverdestination file,. givenReturns itstrue pathif (relative the defaultcopy server location){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version infosucceeds, false if any error occurs.{td}{tr}{tr:id=prs}{td}*Parameters*\\serverPathsourceFile
destinationFile
{td}{tr}{tr:id=ret}{td}*Returns*\\ [JSFileBoolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// varCopy fbased =on plugins.file.convertToRemoteJSFile('/story.txt');
if (f && f.canRead( names.
if (!plugins.file.copyFile("story.txt", "story.txt.copy"))
	application.output("Copy failed.");
// Copy based on JSFile instances.
var f = plugins.file.createFile("story.txt");
var fcopy = plugins.file.createFile("story.txt.copy2");
if (!plugins.file.copyFile(f, fcopy))
	application.output('File can be read.'"Copy failed.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=copyFilecopyFolder|class=node}{tr:id=name}{td}h6.copyFilecopyFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}copyFilecopyFolder{span}{span:id=iets|style=float: left;}\(sourceFilesourceFolder, destinationFiledestinationFolder){span}{td}{tr}{tr:id=des}{td}Copies the sourcefilesourcefolder to the destination folder, filerecursively. Returns true if the copy succeeds, false if any error occurs.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\sourceFilesourceFolder
destinationFiledestinationFolder
{td}{tr}{tr:id=ret}{td}*Returns*\\ [Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// Copy folder based on file names.
if (!plugins.file.copyFilecopyFolder("story.txtstories", "story.txt.stories_copy"))
	application.output("CopyFolder copy failed.");
// Copy folder based on JSFile instances.
var fd = plugins.file.createFile("story.txtstories");
var fcopydcopy = plugins.file.createFile("story.txt.copy2stories_copy_2");
if (!plugins.file.copyFilecopyFolder(fd, fcopydcopy))
	application.output("CopyFolder copy failed.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=copyFoldercreateFile|class=node}{tr:id=name}{td}h6.copyFoldercreateFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[BooleanJSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}copyFoldercreateFile{span}{span:id=iets|style=float: left;}\(sourceFolder, destinationFoldertargetFile){span}{td}{tr}{tr:id=des}{td}CopiesCreates thea sourcefolder to the destination folder, recursivelyJSFile instance. ReturnsDoes truenot ifcreate the copyfile succeeds, false if any error occurson disk.{td}{tr}{tr:id=sncprs}{td}*SinceParameters*\\ Replace with version infotargetFile
{td}{tr}{tr:id=prsret}{td}*ParametersReturns*\\sourceFolder destinationFolder
[JSFile]{td}{tr}{tr:id=retsam}{td}*ReturnsSample*\\[Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{{div:class=sIndent}{code:language=javascript}
// Create Copythe JSFile folderinstance based on the file namesname.
if (!var f = plugins.file.copyFoldercreateFile("stories", "stories_copy"))
	application.output("Folder copy failed.");
// Copy folder based on JSFile instances.
var d = plugins.file.createFile("stories");
var dcopy = plugins.file.createFile("stories_copy_2");
if (!plugins.file.copyFolder(d, dcopynewfile.txt");
// Create the file on disk.
if (!f.createNewFile())
	application.output("Folder copy failedThe file could not be created.");
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createFilecreateFolder|class=node}{tr:id=name}{td}h6.createFilecreateFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFileBoolean]{span}{span:id=iets|style=float: left; font-weight: bold;}createFilecreateFolder{span}{span:id=iets|style=float: left;}\(targetFiletargetFolder){span}{td}{tr}{tr:id=des}{td}Creates a JSFilefolder on instancedisk. DoesReturns nottrue createif the filefolder on disk.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version infois successfully created, false if any error occurs.{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFiletargetFolder
{td}{tr}{tr:id=ret}{td}*Returns*\\ [JSFileBoolean]{td}{tr}{tr:id=seesam}{td}*Also seeSample*\\{div:class=sIndent}{code:language=javascript}
var d = plugins.file.convertToJSFile("newfolder");
if (!plugins.file.createFolder(d))
	application.output("Folder could not be created.");
{code}{div}{td}{tr}{tr:idclass=linklastDetailRow}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tbody}{tbody:id=createTempFile|class=node}{tr:id=name}{td}h6.createTempFile{td}{tr}{tr:id=samsig}{td}*Sample*\\{divspan:class=sIndent}{code:language=javascript}
// Create the JSFile instance based on the file name.
var f = plugins.file.createFile("newfile.txt");
// Create thestyle=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}createTempFile{span}{span:id=iets|style=float: left;}\(filePrefix, fileSuffix){span}{td}{tr}{tr:id=des}{td}Creates a temporary file on disk.
if (!f.createNewFile())
	application.output("The file could not be created.");
{code}{div}{ A prefix and an extension are specified and they will be part of the file name.{td}{tr}{tr:classid=lastDetailRowprs}{td}*Parameters*\\filePrefix
fileSuffix
{td}{tr}{tbody}{tbody:id=createFolder|class=node}{tr:id=nameret}{td}h6.createFolder*Returns*\\ [JSFile]{td}{tr}{tr:id=sigsam}{td}*Sample*\\{spandiv:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}createFolder{span}{span:id=iets|style=float: left;}\(targetFolder){span}{td}{tr}{tr:id=des}{td}Creates a folder on disk. Returns true if the folder is successfully created, false if any error occurs.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFolder
class=sIndent}{code:language=javascript}
var tempFile = plugins.file.createTempFile('myfile','.txt');
application.output('Temporary file created as: ' + tempFile.getAbsolutePath());
plugins.file.writeTXTFile(tempFile, 'abcdefg');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=deleteFile|class=node}{tr:id=name}{td}h6.deleteFile{td}{tr}{tr:id=retsig}{td}*Returns*\\[Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}deleteFile{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=linkdes}{td}*External links*\\{div:class=sIndent}{div}Removes a file from disk. Returns true on success, false otherwise.{td}{tr}{tr:id=samprs}{td}*SampleParameters*\\{div:targetFile
{td}{tr}{tr:id=ret}{td}*Returns*\\ [Boolean]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var
d = plugins.file.convertToJSFile("newfolder");
if (!plugins.file.createFolder(ddeleteFile('story.txt'))
	application.output("Folder could not be created."'File deleted.');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=createTempFiledeleteFolder|class=node}{tr:id=name}{td}h6.createTempFiledeleteFolder{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFileBoolean]{span}{span:id=iets|style=float: left; font-weight: bold;}createTempFiledeleteFolder{span}{span:id=iets|style=float: left;}\(filePrefixtargetFolder, fileSuffixshowWarning){span}{td}{tr}{tr:id=des}{td}CreatesDeletes a temporaryfolder filefrom ondisk diskrecursively. AReturns prefixtrue andon ansuccess, extensionfalse are specified and theyotherwise. If the second parameter is set to true, then a warning will be partissued ofto the file name.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version infouser before actually removing the folder.{td}{tr}{tr:id=prs}{td}*Parameters*\\filePrefixtargetFolder
fileSuffixshowWarning
{td}{tr}{tr:id=ret}{td}*Returns*\\ [JSFileBoolean]{td}{tr}{tr:id=seesam}{td}*Also seeSample*\\{div:class=sIndent}{code:language=javascript}
if (plugins.file.deleteFolder('stories', true))
	application.output('Folder deleted.');
{code}{div}{td}{tr}{tr:idclass=linklastDetailRow}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tbody}{tbody:id=getDesktopFolder|class=node}{tr:id=name}{td}h6.getDesktopFolder{td}{tr}{tr:id=samsig}{td}*Sample*\\{divspan:class=sIndent}{code:language=javascript}
var tempFile = plugins.file.createTempFile('myfile','.txt');
application.output('Temporary file created as: ' + tempFile.getAbsolutePath());
plugins.file.writeTXTFile(tempFile, 'abcdefg');
{code}{divstyle=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}getDesktopFolder{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:classid=lastDetailRowdes}{td}Returns a JSFile instance that corresponds to the Desktop folder of the currently logged in user.{td}{tr}{tbody}{tbody:id=deleteFile|class=node}{tr:id=nameret}{td}h6.deleteFile*Returns*\\ [JSFile]{td}{tr}{tr:id=sigsam}{td}*Sample*\\{spandiv:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}deleteFile{span}{span:id=iets|style=float: left;}\(targetFile){span}class=sIndent}{code:language=javascript}
var d = plugins.file.getDesktopFolder();
application.output('desktop folder is: ' + d.getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDiskList|class=node}{tr:id=name}{td}h6.getDiskList{td}{tr}{tr:id=dessig}{td}Removes a file from disk. Returns true on success, false otherwise.{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getDiskList{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=sncdes}{td}*Since*\\ Replace with version infoReturns an Array of JSFile instances correponding to the file system root folders.{td}{tr}{tr:id=prsret}{td}*ParametersReturns*\\targetFile
{td}{tr}{tr:id=ret}{td}*Returns*\\[Boolean [JSFile]\[]{td}{tr}{tr:id=seesam}{td}*Also seeSample*\\{div:class=sIndent}{code:language=javascript}
var roots = plugins.file.getDiskList();
for (var i = 0; i < roots.length; i++)
	application.output(roots[i].getAbsolutePath());
{code}{div}{td}{tr}{tr:idclass=linklastDetailRow}{td}*External links*\\{div:class=sIndent}{divtd}{tdtr}{trtbody}{trtbody:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
if (plugins.file.deleteFile('story.txt'))
	application.output('File deleted.');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=deleteFoldergetFileSize|class=node}{tr:id=name}{td}h6.deleteFoldergetFileSize{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[BooleanNumber]{span}{span:id=iets|style=float: left; font-weight: bold;}deleteFoldergetFileSize{span}{span:id=iets|style=float: left;}\(targetFolder, showWarningtargetFile){span}{td}{tr}{tr:id=des}{td}DeletesReturns the asize folderof fromthe diskspecified recursively. Returns true on success, false otherwise. If the second parameter is set to true, then a warning will be issued to the user before actually removing the folder.{file.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFoldertargetFile
showWarning
{td}{tr}{tr:id=ret}{td}*Returns*\\ [BooleanNumber]{td}{tr}{tr:id=seesam}{td}*Also seeSample*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
if (code:language=javascript}
var f = plugins.file.deleteFolderconvertToJSFile('stories', true))
	story.txt');
application.output('Folder deleted.''file size: ' + plugins.file.getFileSize(f));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDesktopFoldergetFolderContents|class=node}{tr:id=name}{td}h6.getDesktopFoldergetFolderContents{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getDesktopFoldergetFolderContents{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}Returns a JSFile instance that corresponds to the Desktop folder of the currently logged in user.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFolder, \[fileFilter\], \[fileOption(1=files,2=dirs)\], \[visibleOption(1=visible,2=nonvisible)\], \[lockedOption(1=locked,2=nonlocked)\]){span}{td}{tr}{tr:id=retdes}{td}*Returns*\\[JSFile]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var d = plugins.file.getDesktopFolder();
application.output('desktop folder is: ' + d.getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getDiskList|class=node}{tr:id=name}{td}h6.getDiskList{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getDiskList{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}Returns an Array of JSFile instances correponding to the file system root folders.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\{td}{tr}{tr:id=ret}{td}*Returns*\\[JSFile]\[]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var roots = plugins.file.getDiskList();
for (var i = 0; i < roots.length; i++)
	application.output(roots[i].getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getFileSize|class=node}{tr:id=name}{td}h6.getFileSize{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Number]{span}{span:id=iets|style=float: left; font-weight: bold;}getFileSize{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=des}{td}Returns the size of the specified file.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFile
{td}{tr}{tr:id=ret}{td}*Returns*\\[Number]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var f = plugins.file.convertToJSFile('story.txt');
application.output('file size: ' + plugins.file.getFileSize(f));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getFolderContents|class=node}{tr:id=name}{td}h6.getFolderContents{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getFolderContents{span}{span:id=iets|style=float: left;}\(targetFolder, \[fileFilter\], \[fileOption(1=files,2=dirs)\], \[visibleOption(1=visible,2=nonvisible)\], \[lockedOption(1=locked,2=nonlocked)\]){span}{td}{tr}{tr:id=des}{td}Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFolder
\[fileFilter\]
\[fileOption(1=files,2=dirs)\]
\[visibleOption(1=visible,2=nonvisible)\]
\[lockedOption(1=locked,2=nonlocked)\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[JSFile]\[]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}Returns an array of JSFile instances corresponding to content of the specified folder. The content can be filtered by optional name filter(s), by type, by visibility and by lock status.{td}{tr}{tr:id=samprs}{td}*SampleParameters*\\{div:class=sIndent}{code:language=javascript}
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getHomeDirectory|class=node}{tr:id=name}{td}h6.getHomeDirectorytargetFolder
\[fileFilter\]
\[fileOption(1=files,2=dirs)\]
\[visibleOption(1=visible,2=nonvisible)\]
\[lockedOption(1=locked,2=nonlocked)\]
{td}{tr}{tr:id=sigret}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}getHomeDirectory{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=des}{td}Returns a JSFile instance corresponding to the home folder of the logged in used.*Returns*\\ [JSFile]\[]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var files = plugins.file.getFolderContents('stories', '.txt');
for (var i=0; i<files.length; i++)
	application.output(files[i].getAbsolutePath());
{code}{div}{td}{tr}{tr:idclass=snclastDetailRow}{td}*Since*\\ Replace with version info{td}{tr}{tbody}{tbody:id=getHomeDirectory|class=node}{tr:id=prsname}{td}*Parameters*\\h6.getHomeDirectory{td}{tr}{tr:id=retsig}{td}*Returns*\\{span:style=float: left; margin-right: 5px;}[JSFile]{tdspan}{tr}{trspan:id=see}{td}*Also see*\\{div:class=sIndent}{div=iets|style=float: left; font-weight: bold;}getHomeDirectory{span}{span:id=iets|style=float: left;}\(){span}{td}{tr}{tr:id=linkdes}{td}*External links*\\{div:class=sIndent}{div}Returns a JSFile instance corresponding to the home folder of the logged in used.{td}{tr}{tr:id=ret}{td}*Returns*\\ [JSFile]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var d = plugins.file.getHomeDirectory();
application.output('home folder: ' + d.getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getModificationDate|class=node}{tr:id=name}{td}h6.getModificationDate{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Date]{span}{span:id=iets|style=float: left; font-weight: bold;}getModificationDate{span}{span:id=iets|style=float: left;}\(targetFile){span}{td}{tr}{tr:id=des}{td}Returns the modification date of a file.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\targetFile
{td}{tr}{tr:id=ret}{td}*Returns*\\[Date]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}.{td}{tr}{tr:id=linkprs}{td}*External linksParameters*\\{div:class=sIndent}{div}targetFile
{td}{tr}{tr:id=ret}{td}*Returns*\\ [Date]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var f = plugins.file.convertToJSFile('story.txt');
application.output('last changed: ' + plugins.file.getModificationDate(f));
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=getRemoteList|class=node}{tr:id=name}{td}h6.getRemoteList{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]\[]{span}{span:id=iets|style=float: left; font-weight: bold;}getRemoteList{span}{span:id=iets|style=float: left;}\(serverFolder/serverFolderPath, \[filesOnly\]){span}{td}{tr}{tr:id=des}{td}Retrieves a list of files existing in a folder on the server side (in the path provided, relative to the default server location){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\serverFolder/serverFolderPath
\[filesOnly\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[JSFile]\[]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div}{ [JSFile]\[]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}

{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=moveFile|class=node}{tr:id=name}{td}h6.moveFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}moveFile{span}{span:id=iets|style=float: left;}\(sourceFile, destinationFile){span}{td}{tr}{tr:id=des}{td}Moves the file from the source to the destination place. Returns true on success, false otherwise.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\sourceFile
destinationFile
{td}{tr}{tr:id=ret}{td}*Returns*\\[Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div} [Boolean]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// Move file based on names.
if (!plugins.file.moveFile('story.txt','story.txt.new'))
	application.output('File move failed.');
// Move file based on JSFile instances.
var f = plugins.file.convertToJSFile('story.txt.new');
var fmoved = plugins.file.convertToJSFile('story.txt');
if (!plugins.file.moveFile(f, fmoved))
	application.output('File move back failed.');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=readFile|class=node}{tr:id=name}{td}h6.readFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}byte[]{span}{span:id=iets|style=float: left; font-weight: bold;}readFile{span}{span:id=iets|style=float: left;}\(\[file\], \[size\]){span}{td}{tr}{tr:id=des}{td}Reads all or part of the content from a binary file. If a file name is not specified, then a file selection dialog pops up for selecting a file. (Web Enabled){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\\[file\]
\[size\]
{td}{tr}{tr:id=ret}{td}*Returns*\\byte[]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}){td}{tr}{tr:id=linkprs}{td}*External links*\\{div:class=sIndent}{div}*Parameters*\\ \[file\]
\[size\]
{td}{tr}{tr:id=ret}{td}*Returns*\\byte[]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// Read all content from the file.
var bytes = plugins.file.readFile('big.jpg');
application.output('file size: ' + bytes.length);
// Read only the first 1KB from the file.
var bytesPartial = plugins.file.readFile('big.jpg', 1024);
application.output('partial file size: ' + bytesPartial.length);
// Read all content from a file selected from the file open dialog.
var bytesUnknownFile = plugins.file.readFile();
application.output('unknown file size: ' + bytesUnknownFile.length);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=readTXTFile|class=node}{tr:id=name}{td}h6.readTXTFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[String]{span}{span:id=iets|style=float: left; font-weight: bold;}readTXTFile{span}{span:id=iets|style=float: left;}\(\[file\], \[charsetname\]){span}{td}{tr}{tr:id=des}{td}Read all content from a text file. If a file name is not specified, then a file selection dialog pops up for selecting a file. The encoding can be also specified. (Web Enabled){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\\[file\] \[charsetname\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[String]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{file\]
\[charsetname\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div} [String]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// Read content from a known text file.
var txt = plugins.file.readTXTFile('story.txt');
application.output(txt);
// Read content from a text file selected from the file open dialog.
var txtUnknown = plugins.file.readTXTFile();
application.output(txtUnknown);
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=showDirectorySelectDialog|class=node}{tr:id=name}{td}h6.showDirectorySelectDialog{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}showDirectorySelectDialog{span}{span:id=iets|style=float: left;}\(\[directory suggestion\], \[dialog title text\]){span}{td}{tr}{tr:id=des}{td}Shows a directory selector dialog.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\ \[directory suggestion\]
\[dialog title text\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[JSFile]{td}{tr}{tr:id=see}{td}*Also
see*\\{div:class=sIndent}{div}{\[dialog title text\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div} [JSFile]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var dir = plugins.file.showDirectorySelectDialog();
application.output("you've selected folder: " + dir.getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=showFileOpenDialog|class=node}{tr:id=name}{td}h6.showFileOpenDialog{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Object]{span}{span:id=iets|style=float: left; font-weight: bold;}showFileOpenDialog{span}{span:id=iets|style=float: left;}\(\[selectionMode(0=both,1=Files,2=Dirs)\], \[startDirectory(null=default/previous)\], \[multiselect(true/false)\], \[filterarray\], \[callbackmethod\], \[dialog title text\]){span}{td}{tr}{tr:id=des}{td}Shows a file open dialog. Filters can be applied on what type of files can be selected. (Web Enabled){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\ \[selectionMode(0=both,1=Files,2=Dirs)\]
\[startDirectory(null=default/previous)\]
\[multiselect(true/false)\]
\[filterarray\]
\[callbackmethod\]
\[dialog title text\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[Object]{td}{tr}{tr:id=see}{td}*Also
see*\\{div:class=sIndent}{div}{\[dialog title text\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div} [Object]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// This selects only files ('1'), previous dir must be used ('null'), no multiselect ('false') and
// the filter "JPG and GIF" should be used: ('new Array("JPG and GIF","jpg","gif")').
var file = plugins.file.showFileOpenDialog(1, null, false, new Array("JPG and GIF","jpg","gif"));
application.output("you've selected file: " + file.getAbsolutePath());
//for the web you have to give a callback function that has a JSFile array as its first argument (also works in smart), other options can be set but are not used in the webclient (yet)
var file = plugins.file.showFileOpenDialog(myCallbackMethod)
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=showFileSaveDialog|class=node}{tr:id=name}{td}h6.showFileSaveDialog{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[JSFile]{span}{span:id=iets|style=float: left; font-weight: bold;}showFileSaveDialog{span}{span:id=iets|style=float: left;}\(\[fileName/dir suggestion\], \[dialog title text\]){span}{td}{tr}{tr:id=des}{td}Shows a file save dialog.{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\ \[fileName/dir suggestion\]
\[dialog title text\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[JSFile]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{\]
\[dialog title text\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div} [JSFile]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var file = plugins.file.showFileSaveDialog();
application.output("you've selected file: " + file.getAbsolutePath());
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=streamFilesFromServer|class=node}{tr:id=name}{td}h6.streamFilesFromServer{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}streamFilesFromServer{span}{span:id=iets|style=float: left;}\(file/fileName|fileArray/fileNameArray, serverFile/serverFileName|serverFileArray/serverFileNameArray, \[callbackFunction\]){span}{td}{tr}{tr:id=des}{td}Streams a file or an array of files from the server in a background task to a file (or files) on the client. If provided, calls back a Servoy function when done{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\file/fileName|fileArray/fileNameArray
serverFile/serverFileName|serverFileArray/serverFileNameArray
\[callbackFunction\]
{td}{tr}{tr:id=ret}{td}*Returns*\\void{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{
serverFile/serverFileName|serverFileArray/serverFileNameArray
\[callbackFunction\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div}void{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// transfer the first file of the default server folder to a chosen file on the client
	var dir = plugins.file.getDesktopFolder();
	var file = plugins.file.showFileSaveDialog(dir,'Save file to');
	if (file) {
		var list = plugins.file.getRemoteList('/', true);
		if (list && list.length > 0) {
			plugins.file.streamFilesFromServer(file, list[0], callbackFunction);
		}
	}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=streamFilesToServer|class=node}{tr:id=name}{td}h6.streamFilesToServer{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}void{span}{span:id=iets|style=float: left; font-weight: bold;}streamFilesToServer{span}{span:id=iets|style=float: left;}\(file/fileName|fileArray/fileNameArray, \[serverFile/serverFileName|serverFileArray/serverFileNameArray\], \[callbackFunction\]){span}{td}{tr}{tr:id=des}{td}Streams a file or an array of files to the server in a background task \- with optional relative path(s)/(new) name(s). If provided, calls back a Servoy function when done{td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\file/fileName|fileArray/fileNameArray
\[serverFile/serverFileName|serverFileArray/serverFileNameArray\]
\[callbackFunction\]
{td}{tr}{tr:id=ret}{td}*Returns*\\void{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{|serverFileArray/serverFileNameArray\]
\[callbackFunction\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div}void{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
// send one file:
	var file = plugins.file.showFileOpenDialog( 1, null, false, null, null, 'Choose a file to transfer' );
	if (file) {
		plugins.file.streamFilesToServer( file, callbackFunction );
	}
	// send an array of files:
	var folder = plugins.file.showDirectorySelectDialog();
	if (folder) {
		var files = plugins.file.getFolderContents(folder);
		if (files) {
			plugins.file.streamFilesToServer( files, callbackFunction );
		}
	}
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=writeFile|class=node}{tr:id=name}{td}h6.writeFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}writeFile{span}{span:id=iets|style=float: left;}\(file, binary_data, \[mimeType\]){span}{td}{tr}{tr:id=des}{td}Writes data into a binary file. (Web Enabled){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\file
binary_data
\[mimeType\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{data
\[mimeType\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div} [Boolean]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var bytes = new Array();
	for (var i=0; i<1024; i++)
		bytes[i] = i % 100;
	var f = plugins.file.convertToJSFile('bin.dat');
	if (!plugins.file.writeFile(f, bytes))
		application.output('Failed to write the file.');
	// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
	var mimeType = 'application/vnd.ms-excel'
	if (!plugins.file.writeFile(f, bytes, mimeType))
		application.output('Failed to write the file.');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=writeTXTFile|class=node}{tr:id=name}{td}h6.writeTXTFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}writeTXTFile{span}{span:id=iets|style=float: left;}\(file, text_data, \[charsetname\], \[mimeType\]){span}{td}{tr}{tr:id=des}{td}Writes data into a text file. (Web Enabled){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\file
text_data
\[charsetname\]
\[mimeType\]
{td}{tr}{tr:id=ret}{td}*Returns*\\[Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}\]
{td}{tr}{tr:id=linkret}{td}*External linksReturns*\\{div:class=sIndent}{div}{ [Boolean]{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var fileNameSuggestion = 'myspecialexport.tab'
	var textData = 'load of data...'
	var success = plugins.file.writeTXTFile(fileNameSuggestion, textData);
	if (!success) application.output('Could not write file.');
	// For file-encoding parameter options (default OS encoding is used), http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
	// mimeType variable can be left null, and is used for webclient only. Specify one of any valid mime types as referenced here: http://www.w3schools.com/media/media_mimeref.asp'
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{tbody:id=writeXMLFile|class=node}{tr:id=name}{td}h6.writeXMLFile{td}{tr}{tr:id=sig}{td}{span:style=float: left; margin-right: 5px;}[Boolean]{span}{span:id=iets|style=float: left; font-weight: bold;}writeXMLFile{span}{span:id=iets|style=float: left;}\(file, xml_data){span}{td}{tr}{tr:id=des}{td}Writes data into an XML file. The file is saved with the encoding specified by the XML itself. (Web Enabled){td}{tr}{tr:id=snc}{td}*Since*\\ Replace with version info{td}{tr}{tr:id=prs}{td}*Parameters*\\file
xml_data
{td}{tr}{tr:id=ret}{td}*Returns*\\ [Boolean]{td}{tr}{tr:id=see}{td}*Also see*\\{div:class=sIndent}{div}{td}{tr}{tr:id=link}{td}*External links*\\{div:class=sIndent}{div}{td}{tr}{tr:id=sam}{td}*Sample*\\{div:class=sIndent}{code:language=javascript}
var fileName = 'form.xml'
var xml = controller.printXML()
var success = plugins.file.writeXMLFile(fileName, xml);
if (!success) application.output('Could not write file.');
{code}{div}{td}{tr}{tr:class=lastDetailRow}{td}{td}{tr}{tbody}{table}