Skip to main content
Participating Frequently
September 27, 2009
Question

How can FMS create a text file and write data into it in the Server application folders?

  • September 27, 2009
  • 1 reply
  • 1248 views

Recently, I writed a programe about creating a text file and writing data into it in the server application folder. My code is as following:

           var fileObj = new File("/MyApp/test.txt");
           if( fileObj !=  null)
           {
                  if(fileObj.open( "text", "append"))
                  {
                        fileObj.write( "                                                      ———— Chat Info Backup ————\r\n" );
                        fileObj.close( );
                        trace("Chat info backup document :" +  fileObj.name + " has been created successfully!");    
                  }
            }

But when I run it, FMS throw the error as following: File operation open failed  ;  TypeError: fileObj has no properties.

Can you help me ? Thanks in advance.

Supplement: The text file named test.txt doesn't exist before create the fileObj, an instance of File Class.

    This topic has been closed for replies.

    1 reply

    September 28, 2009

    Is MyApp the name of the application directory, or is it a child of the application directory? If myApp is the app name, just use test.txt as the path flag in the file constructor.