Important! A new Community experience launched on September 26, 2017. Read more about it here or continue to Base Camp.
Voting: 
Vote up!
0 Votes
1 Replies

File creation issue - Studio 6.5

Magesh Rathnam on Apr 04, 2017 11:29 EDT

Posted In
Kony Answered Certificate
Vote up!
0 votes
Vote down!

Hi Magesh,

Below is the code to create file in the file system,

var path = kony.io.FileSystem.getDataDirectoryPath();                                                                                                            //create the file in directory photos                                                                                                                                           var myfile = kony.io.FileSystem.getFile(path + "/photos/" + lMediaName + ".jpg");                                                                           var filecreated = myfile.createFile();

Where in case of Windows and Android if the given directory is not availabel then system will create the directory and will write the file. where in case of iOS if the directory is not avaialble it will return false.

To make if work in iOS

Please add the below code snippet before

var myfile = kony.io.FileSystem.getFile(path + "/photos/" + lMediaName + ".jpg");"

var myDirectory = kony.io.FileSystem.getFile(path + "/photos/");
var directorycreated = myDirectory.createDirectory();

As in case of iPhone, file won't be created if directory does not exist.

 

Thanks

Apr 06, 2017 00:41 EDT
Bronze