XLF

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
(By 4D Interactive Studio)
(By 4D Interactive Studio)
Line 9: Line 9:
  
 
----
 
----
 +
 +
IO.js
  
 
<javascript>
 
<javascript>
 +
 +
import System.IO;
 +
 +
class IO
 +
{
 +
// ------------------------------ File ------------------------------ //
 +
 +
public static function ExistsFile ( url : String )
 +
{
 +
var info : FileInfo = new FileInfo ( url );
 +
 +
return info.Exists;
 +
}
 +
 +
public static function RemoveFile ( url : String )
 +
{
 +
var info : FileInfo = new FileInfo ( url );
 +
 +
if ( info.Exists )
 +
info.Delete ( );
 +
}
 +
 +
public static function WriteFile ( url : String, string : String )
 +
{
 +
var writer : StreamWriter;
 +
var info : FileInfo = new FileInfo ( url );
 +
 +
if ( info.Exists )
 +
info.Delete ( );
 +
 +
writer = info.CreateText ( );
 +
 +
writer.Write ( string );
 +
writer.Close ( );
 +
}
 +
 +
public static function ReadFile ( url : String )
 +
{
 +
var info : FileInfo = new FileInfo ( url );
 +
 +
if ( ! info.Exists )
 +
return "";
 +
 +
var reader : StreamReader = File.OpenText ( url );
 +
var readedString : String = reader.ReadToEnd ( ); 
 +
 +
reader.Close ( );
 +
 +
return readedString;
 +
}
 +
}
  
 
</javascript>
 
</javascript>

Revision as of 16:37, 21 October 2011

X-Language-File

By 4D Interactive Studio

XLF is a class to read and write files.


IO.js

<javascript>

import System.IO;

class IO { // ------------------------------ File ------------------------------ //

public static function ExistsFile ( url : String ) { var info : FileInfo = new FileInfo ( url );

return info.Exists; }

public static function RemoveFile ( url : String ) { var info : FileInfo = new FileInfo ( url );

if ( info.Exists ) info.Delete ( ); }

public static function WriteFile ( url : String, string : String ) { var writer : StreamWriter; var info : FileInfo = new FileInfo ( url );

if ( info.Exists ) info.Delete ( );

writer = info.CreateText ( );

writer.Write ( string ); writer.Close ( ); }

public static function ReadFile ( url : String ) { var info : FileInfo = new FileInfo ( url );

if ( ! info.Exists ) return "";

var reader : StreamReader = File.OpenText ( url ); var readedString : String = reader.ReadToEnd ( );

reader.Close ( );

return readedString; } }

</javascript>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox