My objective is to write text in a file. (This text file will later be used by the BarTender Server and print lables).
I am working on a proof of concept to write simple text file, but failing. I used the form “APEFTPosting” to understand how it works. But its not working for me.
I did the following steps.
- Added a Secondary Collection “SLFileServerFileContents” on the form. (no other action on this Secondary Collection).
- On a button click event, I wrote the following Form Script Method:
Function XXX_GenerateTestFile As Boolean
Dim fileName As String = "MyFirstFile.txt"
Dim fileExtension As String = "txt"
Dim fileContent As String = "Contents of the First File"
Dim logicalFolderName As String = "MyLogicalFolder"
Dim fileServer As String = "MyFileTest"
Dim folderTemplate As String = "out"
Dim accessDepth As String = "2"
Dim useServerCheckStr As String = "0"
Dim errMsg As String = ""
Dim success As Boolean = False
Dim fileSpec As String = folderTemplate.TrimEnd("/"c) + "" + fileName + "|" + fileExtension + "|" + accessDepth + "|" + useServerCheckStr
Dim fileContentBase64String As String = TextToBase64String(fileContent)
ThisForm.GetSecondaryIDOCollection(2).SetObjectProperty("BinaryContent", 0, fileContentBase64String)
success = Application.FileServer.ExportToFileSeverFromCollection(ThisForm.Name, "object2", "BinaryContent", fileServer,
logicalFolderName, fileSpec, 0, errMsg)
Application.ShowMessage(success.ToString())
Application.ShowMessage(errMsg)
ThisForm.GetSecondaryIDOCollection(2).Refresh()
XXX_GenerateTestFile = True
End Function
- In the above code, success is false. i.e. FileServer.ExportToFileSeverFromCollection( is returning some error).
- On reviewing errMsg, I get: “Unknown error resulting in empty message.”
- Please note that My File Server and Logical Folders are configured correctly. I can upload and view files from “File Maintenance” Form.
I am open for an alternate way to write text tile in a logical folder.