Asynchronously copies all the available data from the input stream into the output stream. The input stream is automatically closed at the end. Returns an object that should be used as the sender filter. Example: WaitFor (File.Copy2Async(in, out)) Complete (SuccessAsBoolean)
Log("Success: " & Success)
Asynchronously copies the source file to the target path. Note that it is not possible to copy files to the Assets folder. Returns an object that should be used as the sender filter. Example: WaitFor (File.CopyAsync(File.DirAssets, "1.txt", File.DirTemp, "1.txt")) Complete (SuccessAsBoolean)
Log("Success: " & Success)
Delete (DirAsString, FileNameAsString) AsBoolean
Deletes the specified file. If the file name is a directory then it must be empty in order to be deleted. Returns true if the file was successfully deleted. Files in the assets folder cannot be deleted.
DirAppAsString [read only]
Returns the application folder.
DirAssetsAsString [read only]
Returns a reference to the files added to the Files tab. These files are read-only (in Release mode).
DirData (AppNameAsString) AsString
Returns the path to a folder that is suitable for writing files. On Windows, folders under Program Files are read-only. Therefore File.DirApp will be read-only as well. This method returns the same path as File.DirApp on non-Windows computers. On Windows it returns the path to the user data folder. For example: C:\Users\[user name]\AppData\Roaming\[AppName]
DirTempAsString [read only]
Returns the temporary folder.
Exists (DirAsString, FileNameAsString) AsBoolean
Returns true if the specified FileName exists in the specified Dir. Note that the file system is case sensitive. This method does not support File.DirAssets.
Example: IfFile.Exists(File.DirApp, "MyFile.txt") Then ...
GetFileParent (FileNameAsString) AsString
Returns the path of the file or folder parent.
GetName (FilePathAsString) AsString
Returns the file name from the full path (or the directory name in case of a directory).
GetUri (DirAsString, FileNameAsString) AsString
Returns a Uri string ("file://...") that points to the given file.
Returns the last modified date of the specified file. This method does not support files in the assets folder. Example: DimdAsLong d = File.LastModified(File.DirApp, "1.txt")
Msgbox(DateTime.Date(d), "Last modified")
ListFiles (DirAsString) AsList
Returns a read only list with all the files and directories which are stored in the specified path. An uninitialized list will be returned if the folder is not accessible. This method does not support the assets folder.
ListFilesAsync (DirAsString) AsObject
Asynchronous version of ListFiles. Should be used with Wait For. Example: WaitFor (File.ListFilesAsync(Dir)) Complete (SuccessAsBoolean, FilesAsList)
MakeDir (ParentAsString, DirAsString)
Creates the given folder (creates all folders as needed). Example: File.MakeDir(File.DirApp, "music/90")
Opens (or creates) the specified file which is located in the Dir folder for writing. If Append is true then the new data will be written at the end of the existing file. This method does not support files in the assets folder.
Reads the entire file and returns a List with all lines (as strings). Example: DimList1AsList List1 = File.ReadList(File.DirApp, "1.txt")
Fori = 0toList1.Size - 1 Log(List1.Get(i))
Next
ReadMap (DirAsString, FileNameAsString) AsMap
Reads the file and parses each line as a key-value pair (of strings). See this link for more information about the actual format: Properties format. You can use File.WriteMap to write a map to a file. Note that the order of items in the map may not be the same as the order in the file.
Similar to ReadMap. ReadMap2 adds the items to the given Map. By using ReadMap2 with a populated map you can force the items order as needed. Example: DimmAsMap m.Initialize m.Put("Item #1", "")
m.Put("Item #2", "")
m = File.ReadMap2(File.DirApp, "settings.txt", m)
Writes each item in the list as a single line. Note that a value containing CRLF will be saved as two lines (which will return two item when read with ReadList). All values will be converted to strings. Example: File.WriteList (File.DirApp, "mylist.txt", List1)
Creates a new file and writes the given map. Each key value pair is written as a single line. All values are converted to strings. See this link for more information about the actual format: Properties format. You can use File.ReadMap to read this file.
A stream that you can read from. Usually you will pass the stream to a "higher level" object like TextReader that will handle the reading. You can use File.OpenInput to get a file input stream.
Use File.OpenInput to get a file input stream. This method should be used to read data from a bytes array. Initializes the input stream and sets it to read from the specified bytes array. StartOffset - The first byte that will be read. MaxCount - Maximum number of bytes to read.
Reads up to MaxCount bytes from the stream and writes it to the given Buffer. The first byte will be written at StartOffset. Returns the number of bytes actually read. Returns -1 if there are no more bytes to read. Otherwise returns at least one byte. Example: Dimbuffer(1024) Asbyte count = InputStream1.ReadBytes(buffer, 0, buffer.length)
A stream that you can write to. Usually you will pass the stream to a "higher level" object like TextWriter which will handle the writing. Use File.OpenOutput to get a file output stream.
Use File.OpenOutput to get a file output stream. This method should be used to write data to a bytes array. StartSize - The starting size of the internal bytes array. The size will increase if needed.
IsInitializedAsBoolean
ToBytesArrayAsByte()
Returns a copy of the internal bytes array. Can only be used when the output stream was initialized with InitializeToBytesArray.
Reads characters from the stream and into the Buffer. Reads up to Length characters and puts them in the Buffer starting as StartOffset. Returns the actual number of characters read from the stream. Returns -1 if there are no more characters available.
ReadAllAsString
Reads all of the remaining text and closes the stream.
ReadLineAsString
Reads the next line from the stream. The new line characters are not returned. Returns Null if there are no more characters to read.
Example: DimReaderAsTextReader Reader.Initialize(File.OpenInput(File.InternalDir, "1.txt"))
DimlineAsString line = Reader.ReadLine DoWhileline <> Null Log(line)
line = Reader.ReadLine Loop Reader.Close
ReadListAsList
Reads the remaining text and returns a List object filled with the lines. Closes the stream when done.
ReadyAsBoolean
Tests whether there is at least one character ready for reading without blocking.
Skip (NumberOfCharacetersAsInt) AsInt
Skips the specified number of characters. Returns the actual number of characters that were skipped (which may be less than the specified value).
Example: DimWriterAsTextWriter Writer.Initialize(File.OpenOutput(File.DirDefaultExternal, "1.txt", False))
Writer.WriteLine("This is the first line.")
Writer.WriteLine("This is the second line.")
Writer.Close
Initializes this object by wrapping the given OutputStream using the specified encoding.
IsInitializedAsBoolean
Write (TextAsString)
Writes the given Text to the stream.
WriteLine (TextAsString)
Writes the given Text to the stream followed by a new line character. Example: DimWriterAsTextWriter Writer.Initialize(File.OpenOutput(File.DirDefaultExternal, "1.txt", False))
Writer.WriteLine("This is the first line.")
Writer.WriteLine("This is the second line.")
Writer.Close
WriteList (ListAsList)
Writes each item in the list as a single line. Note that a value containing CRLF will be saved as two lines (which will return two item when read with ReadList). All values will be converted to strings.
Top