{"id":21232,"date":"2022-04-11T13:56:06","date_gmt":"2022-04-11T11:56:06","guid":{"rendered":"https:\/\/help.openbee.com\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/jse_file\/"},"modified":"2026-05-13T09:35:23","modified_gmt":"2026-05-13T07:35:23","slug":"jse_file","status":"publish","type":"page","link":"https:\/\/help.openbee.com\/en\/open-bee-scan-capture\/knowledge-base\/how-to-guides\/scripts-in-capture\/jse_file\/","title":{"rendered":"JSE_File"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>When copying and pasting, an invisible character can be added to the beginning of your file&#8217;s path (path). As a result, your file will not be found correctly, the most reliable solution is to copy the path manually<\/p>\n<\/blockquote>\n\n<h1 class=\"wp-block-heading\" id=\"JSE_File-Introduction\">Introduction<\/h1>\n\n<p>The JSE_File class allows you to interact with system files through a number of methods<\/p>\n\n<h1 class=\"wp-block-heading\" id=\"JSE_File-Fonctions\">Duties<\/h1>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-createDirectory(stringpathDirectory):void\">createDirectory(string pathDirectory): void<\/h3>\n\n<p>This method creates a directory on the system using pathDirectory as the path<\/p>\n\n<pre class=\"wp-block-code\"><code>JSE_File.createDirectory(\"C:\\Users\\openbee\\Documents\\Test\\NouveauTest\"); \/\/Cr\u00e9er le r\u00e9pertoire NouveauTest<\/code><\/pre>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-getDirectories(stringdirectoryPath):String[]\">getDirectories(string directoryPath): String[]<\/h3>\n\n<p>This function allows you to obtain the name of the directories contained in the directory passed as a parameter in the form of a string list<\/p>\n\n<pre class=\"wp-block-code\"><code>return JSE_File.getDirectories(\"C:\\Users\\openbee\\Documents\\Test\");<\/code><\/pre>\n\n<p><strong>Result<\/strong><\/p>\n\n<pre class=\"wp-block-code\"><code>&#91;\n\t\"C:\\Users\\openbee\\Documents\\Test\\BasicTest\",\n\t\"C:\\Users\\openbee\\Documents\\Test\\NouveauTest\",\n\t\"C:\\Users\\openbee\\Documents\\Test\\PreviousTest\"\n]<\/code><\/pre>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-getFiles(stringdirectoryPath):String[]\">getFiles(string directoryPath): String[]<\/h3>\n\n<p>This function allows you to obtain the names of the files contained in the directory passed as a parameter in the form of a string list<\/p>\n\n<pre class=\"wp-block-code\"><code>return JSE_File.getFiles(\"C:\\Users\\openbee\\Documents\\Test\");<\/code><\/pre>\n\n<p><strong>Result<\/strong><\/p>\n\n<pre class=\"wp-block-code\"><code>&#91;\n\t\"C:\\Users\\openbee\\Documents\\Test\\NouveauTestFile.txt\",\n\t\"C:\\Users\\openbee\\Documents\\Test\\TestFile1.txt\"\n]<\/code><\/pre>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-deleteFile(stringfilename):void\">deleteFile(string filename): void<\/h3>\n\n<p>This method deletes the file whose path is passed as a parameter<\/p>\n\n<pre class=\"wp-block-code\"><code>JSE_File.deleteFile(\"C:\\Users\\openbee\\Documents\\Test\\TestFile1.txt\");<\/code><\/pre>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-downloadFile(OBWebResponsewsResponse,stringfileName):void\">downloadFile(OBWebResponse wsResponse, string fileName): void<\/h3>\n\n<p>This method downloads a file contained in the OBWebResponse object passed as a parameter. This method is usually used in addition to a web service call whose result is not a string but a file specifying:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>fileName: The path of the file that will be created after uploading<\/li>\n<\/ul>\n\n<pre class=\"wp-block-code\"><code>var ws = new JSE_WebService(\"127.0.0.1\", \"http\", 8090);\r\nvar res = ws.send(\"\/ws\/document\/file\/\"+INTERNAL_DOCUMENT_ID, \"GET\", {\"Authorization\" : \"Bearer \"+ CAPTURE_WS_TOKEN}, -1, false);\r\nJSE_File.downloadFile(res, \"C:\\Users\\openbee\\Documents\\Test\\TestFromResponseDownload.pdf\");<\/code><\/pre>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-writeFile(stringpPath,stringpContent,stringpEncoding):void\">writeFile(string pPath, string pContent, string pEncoding): void<\/h3>\n\n<p>This method writes the contents of your pContent string to the specified pPath file. If the file does not exist, it is created (if the rights are sufficient), otherwise it is overwritten.<\/p>\n\n<p>The pEncoding parameter is optional (Version 3.8.3-554).<\/p>\n\n<pre class=\"wp-block-code\"><code>JSE_File.writeFile(\"C:\\Users\\openbee\\Documents\\Test\\testCSV.csv\",\"COL1;COL2nTOTO;TITI\");<\/code><\/pre>\n\n<p>The encodings available depend on the platform where the script is run. In the case of unsupported encoding, a warning message is present in the logs, as well as a list of encoding available for the platform. Examples of supported encodings: &#8220;iso-8859-13&#8221;, &#8220;utf-8&#8221;, &#8220;us-ascii&#8221; ..<\/p>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-readFile(stringpPath,stringpEncoding):String\">readFile(string pPath, string pEncoding): String<\/h3>\n\n<p>This function allows you to read the contents of a pPath file passed as a parameter if the user&#8217;s rights allow it<\/p>\n\n<p>The pEncoding parameter is optional (Version 3.8.3-554).<\/p>\n\n<pre class=\"wp-block-code\"><code>return JSE_File.readFile(\"C:\\Users\\openbee\\Documents\\Test\\testCSV.csv\");<\/code><\/pre>\n\n<p><strong>Result<\/strong><\/p>\n\n<pre class=\"wp-block-code\"><code>COL1;COL2\nTOTO;TITI<\/code><\/pre>\n\n<p>The encodings available depend on the platform where the script is run. In the case of unsupported encoding, a warning message is present in the logs, as well as a list of encoding available for the platform. Examples of supported encodings: &#8220;iso-8859-13&#8221;, &#8220;utf-8&#8221;, &#8220;us-ascii&#8221;..<\/p>\n\n<h3 class=\"wp-block-heading\" id=\"JSE_File-addLogMessage(stringpMessage):void\">addLogMessage(string pMessage): void<\/h3>\n\n<p>This method allows you to write logs to help you find your way around your scripts. These logs will output to the file that corresponds to the client console logs. Depending on the user&#8217;s rights, these can be found:<\/p>\n\n<ul class=\"wp-block-list\">\n<li>[DOSSIER INSTALLATION DE LA CONSOLE]\\Bin\\Log\\EasyCaptureUI\\EASYCAPTUREMUIL_YYYYMMDD.txt<\/li>\n\n\n\n<li>C:\\Users\\*****\\AppData\\Local\\VirtualStore\\Program Files (x86)\\OpenBee\\Open Bee\u2122 Scan Capture \\Console\\Bin\\Log\\EasyCaptureUI\\EASYCAPTUREMUIL_YYYYMMDD.txt<\/li>\n<\/ul>\n\n<pre class=\"wp-block-code\"><code>JSE_File.addLogMessage(\"Debut de mon script\");\nvar a = 0;\nvar b = 1;\nif(a == b)\n\tJSE_File.addLogMessage(\"Mes variables sont \u00e9gales\");\nelse\n\tJSE_File.addLogMessage(\"Mes variables sont in\u00e9gales: a=\"+a+\" b=\"+b);<\/code><\/pre>\n\n<p><strong>Result in log file EASYCAPTUREMUIL_YYYYMMDD.txt<\/strong><\/p>\n\n<pre class=\"wp-block-code\"><code>22\/01\/2020 15:17:18--INFO --&#91;EasyCaptureUI.Services.JSEngine.OBJSEngine.addLogMessage] \nDebut de mon script\n22\/01\/2020 15:17:18--INFO --&#91;EasyCaptureUI.Services.JSEngine.OBJSEngine.addLogMessage] \nMes variables sont in\u00e9gales: a=0 b=1<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When copying and pasting, an invisible character can be added to the beginning of your file&#8217;s path (path). As a result, your file will not be found correctly, the most reliable solution is to copy the path manually Introduction The JSE_File class allows you to interact with system files through a number of methods Duties [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":21211,"menu_order":4,"comment_status":"closed","ping_status":"closed","template":"templates\/ob-help-products.php","meta":{"footnotes":""},"class_list":["post-21232","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/comments?post=21232"}],"version-history":[{"count":1,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21232\/revisions"}],"predecessor-version":[{"id":21233,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21232\/revisions\/21233"}],"up":[{"embeddable":true,"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/pages\/21211"}],"wp:attachment":[{"href":"https:\/\/help.openbee.com\/en\/wp-json\/wp\/v2\/media?parent=21232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}