-
Notifications
You must be signed in to change notification settings - Fork 3
kiwi.io.File
The File class is an abstract representation of file and directory pathnames. Kiwi's File type can be found under kiwi/io/File.bi path
function File.isFile() as Boolean
Tests whether the file denoted by this abstract pathname is a normal file.
@return true if and only if the file denoted by this abstract pathname exists and is a normal file, otherwise return false
function File.isFile() as Boolean
Tests whether the file denoted by this abstract pathname is a normal directory. @return true if and only if the file denoted by this abstract pathname exists and is a directory, otherwise return false
function File.exists() as Boolean
Tests whether the file or directory denoted by this abstract pathname exists. Returns true if and only if the file or directory denoted by this abstract pathname exists. @return true if and only if the file denoted by this abstract pathname exists, otherwise return false
function File.canRead() as Boolean
Tests whether the application can read the file denoted by this abstract pathname.
@return true if and only if the file specified by this abstract pathname exists and can be read by the application. Otherwise it returns false
function File.canWrite() as Boolean
Tests whether the application can write the file denoted by this abstract pathname.
@return true if and only if the file system actually contains a file denoted by this abstract pathname and the application is allowed to write to the file.Otherwise it returns false
function File.createNewFile() as Boolean
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.
@return true if and only the file is created
function File.delete() as Boolean
Deletes the file or directory denoted by this abstract pathname.
@return true if and only the file is delete
sub File.listFiles(files() as File)
Returns an array of Files contained in the directory denoted by this abstract pathname.
sub File.setPathName(ByVal pathname as String)
Sets the pathname of this File instance
function File.getPath() as String
Converts abstract pathname into a pathname string and returns it.
function File.getSize() as LongInt
Returns the size of a file (in bytes). The size may differ from the actual size on the file system due to compression, support for sparse files, or other reasons.
#include once "kiwi\kiwi.bi"
#include once "kiwi\io.bi"
' Declare a new file
Dim myFile as File = File("C:\Users\nsiat\Desktop\Test.txt")
' Check if file exists and print the result
print "File exists: " & myFile.exists()
#include once "kiwi\kiwi.bi"
#include once "kiwi\io.bi"
' Declare a new file
Dim myFile as File = File("C:\Users\nsiat\Desktop\Test.txt")
' Try creating the file
if myFile.createNewFile() = true then
print "File " & myFile.getPath() & " has been created!"
else
print "Unable to create file " & myFile.getPath() & "!"
end if
#include once "kiwi\kiwi.bi"
#include once "kiwi\io.bi"
' Declare a new file
Dim myFile as File = File("C:\Users\nsiat\Desktop\Test2.txt")
' Check if file exists and try delete it
if myFile.exists() then
if myFile.deleteFile() then
print "File " & myFile.getPath() & " has been deleted!"
else
print "Unable to delete file " & myFile.getPath()
end if
else
print "File doesn't exist!"
end if
#include once "kiwi\kiwi.bi"
#include once "kiwi\io.bi"
' Declare a new file
Dim myFile as File = File("C:\Users\nsiat\Desktop\Test.txt")
' Check if path leads to a file
if myFile.isFile() then
print "Path " & myFile.getPath() & " leads to a file"
end if
' Check if path leads to a directory
if myFile.isDirectory() then
print "Path " & myFile.getPath() & " leads to a directory"
end if
#include once "kiwi\kiwi.bi"
#include once "kiwi\io.bi"
' Declare a new file
Dim myDirectory as File = File(Environ("userprofile"))
Dim filesInDirectory() as File ' This array holds the files included in the directory
myDirectory.listFiles(filesInDirectory()) ' List all files from the directory to filesInDirectory() array
print "Files count: " & ubound(filesInDirectory) + 1
for i as Integer = 0 to ubound(filesInDirectory)
print "File " & i & " " & filesInDirectory(i).getPath()
next
- MySQL/MariaDB - Coming to v1.0.2
- ArrayList
- Comparator
- HashMap - Coming to v1.0.2
- Queue