4DIS - IO

From Unify Community Wiki
Jump to: navigation, search

IO

4D IS - Back


You need this class to save and load strings.

Functions :

IO.ExistsFile ( "...url..." ) : boolean;
IO.RemoveFile ( "...url..." );
IO.WriteFile ( "...url...", "...text..." );
IO.ReadFile ( "...url..." ) : String;

IO.js

import System.IO;
 
class IO
{
	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;
	}
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox