Unicode Controls & Classes for VB6 - Version 4

clsUniFile Class

This class permits you to manage UNICODE/ANSI/UTF8 files. Supports extended Unicode and UNC path (up to 32000 characters, with Unicode path and filenames).
Methods starting with "st_" work without an opened file handle and should be treated as "Static"

Enums
Name Description
eFileEncoding File encoding constants
eUniFileAccess File access values
eUniFileAttributes File attributes, the file attribute can be a combination of these constants
eUniFileCreationDisposition File creation modes
eUniFileMoveExFlags Move file flags
eUniFilePointerPos File pointer offsets
eUniFileShareMode File sharing mode
Events
Name Description
Properties
Name Type Description
Methods
Name Type Description
CloseFile Closes the opened file, automatically called when the class terminates
Eof (Boolean) Returns true if the file pointer is at the End Of File
Flush (Boolean) Flushes pending file operations
GetBool (Boolean) Gets a boolean value from the file
GetDouble (Double) Gets a double value from file
GetFilePos (Currency) Returns the position of the file pointer; -1 if the file is not opened
GetInt (Integer) Gets an integer value from the file
GetLong (Long) Gets a long value from the file
GetNumCharsAndString (String) Gets a string (saved using the function [WriteNumCharsAndString]) from a binary file
IsFileOpen (Boolean) Checks if the class is managing a file
LOF (Currency) Gets the size of the opened file
OpenedFileHandle (Long) Returns the handle of the opened file managed by the class
OpenedFileName (String) Returns the name of the opened file managed by the class
OpenFileAppend (Boolean) Uses [OpenFileGeneric] for opening a file for appending
OpenFileGeneric (Boolean) Main function for opening files
OpenFileRead (Boolean) Uses [OpenFileGeneric] for opening a file for reading
OpenFileWrite (Boolean) Uses [OpenFileGeneric] for opening a file for writing
ReadAnsiLine (Boolean) Reads bytes from file until a LF char is found; returns True is the function finished correctly
ReadAny (Boolean) Reads n bytes from file and fill a certain variable
ReadBOM (eFileEncoding) Identifies the encoding used in file by reading the BOM at the start of the file
ReadBool (Boolean) Reads a Boolean value from file and returns True if the operation finished correctly
ReadByte (Boolean) Reads a byte from file and returns True if the operation finished correctly
ReadBytes (Boolean) Reads n byte from file and returns True if the operation finished correctly
ReadDouble (Boolean) Reads a Double value from file and returns True if the operation finished correctly
ReadInt (Boolean) Reads an Integer value from file and returns True if the operation finished correctly
ReadLine (Boolean) Read a line from a file with the given encoding
ReadLong (Boolean) Reads a long from file (4 bytes) and returns True iìf the operation finished correctly
ReadNumCharsAndString (Boolean) Same as [GetNumCharsAndString] but returns True if the operation finished correctly
ReadUnicodeLine (Boolean) Reads bytes from file until a LF char is found; returns True is the function finished correctly
ReadUTF8Line (Boolean) Reads bytes from file until a LF char is found; returns True is the function finished correctly
SetEndOfFileHere (Boolean) Sets the EOF at the current file position
SetFilePos Moves the file pointer to the specified position from the specified starting point
st_CopyFile (Boolean) Copies a file
st_CopyFolderContent (Boolean) Copies content of a specified folder (and sub-folders) to another
st_DirExist (Boolean) Returns True if the specified folder exists
st_FileExist (Boolean) Returns True if the specified file exists
st_FileExt (String) Returns the extension of a specified file (without the . char)
st_FileHasAttribute (Boolean) Checks if the specified file has a certain attribute
st_FileLen (Currency) Returns the lenght in bytes of the specified file
st_FileName (String) Returns only the filename from the given file
st_FileNameNoExt (String) Returns only the filename without extension and path from the specified file
st_FilePath (String) Returns the path of a specified filename
st_GetCurDir (String) Returns the current folder (that can be different from the program executable!)
st_GetFileAttr (eUniFileAttributes) Returns the attributes of a certain file; the return value is a combination of [eUniFileAttributes] enum
st_GetFileDate Returns Datetime info about a specified file
st_GetFileEncoding (eFileEncoding) Returns the encoding of a given filename
st_GetTempPath (String) Returns the Windows temporary path
st_IsLocalOrUNCPathAbs (Boolean) Returns True if the given path is a UNC or Local path
st_IsLocalOrUNCPathRel (Boolean) Returns True if the given path can be a relative local or UNC path (searches for a '\' char)
st_IsLocalPathAbs (Boolean) Returns True if the given path starts with a disc c:\xxx
st_IsUNCPathAbs (Boolean) Returns True if the given path if a UNC path \\server\xxx
st_IsWebPathAbs (Boolean) Returns True if the given web path is "absolute" (contains a protocol at the beginning ex: http://)
st_IsWebPathRel (Boolean) Returns True if the given path is a relative web path (it searches for a '/' char)
st_LocalizePath (String) Returns the local file name corresponding to a file:/// web path, removes also URL parameters
st_MakePath (Boolean) Creates a complete path (creates folders and subfolders); returns True if the path exists at the end of the execution
st_MkDir (Boolean) Creates a folder
st_MoveFile (Boolean) Moves a file to a place; returns True if the operation finished correctly
st_MoveFolderContent (Boolean) Moves content of a specified folder (and sub-folders) to another
st_NoBackSlash (String) Returns a path with no backslashes at the end
Very useful when concatenating paths and filenames
st_NoSlashWeb (String) Returns a path with no slashes at the end
Very useful when concatenating web paths and filenames
st_OneBackSlash (String) Returns a path with only one backslash at the end (if there are no backslashes or more than one, it will return only one backslash)
Very useful when concatenating paths and filenames
st_OneSlashWeb (String) Returns a path with only one slash at the end (if there are no slashes or more than one, it will return only one slash)
Very useful when concatenating web paths and filenames
st_RmDir (Boolean) Deletes a folder
st_RmDirRic (Boolean) Deletes a folder and all files and sub-folders inside
st_RmFile (Boolean) Deletes a file
st_RmFiles (Boolean) Deletes many files at a time
st_SetCurDir (Boolean) Sets the current folder
st_SetFileAttr (Long) Sets a group of attributes to the given filename
st_StringToTextFile (Boolean) Creates a file with the specified string
st_TextFileToString2a (Boolean) Load a textfile and returns the contained text; This function attemps to check the correct encoding then it will read the file in the right way
st_UniAppPath (String) Returns the Unicode application path
st_UniCommandLine (String) Returns the Unicode command line for the current executable
st_WebizePath (String) Returns a web path of the given file
WriteAnsiLine (Boolean) Writes an ANSI line to a file (with vbCrLf at the end)
WriteAny (Boolean) Writes a generic variable to a file
WriteBOM (Boolean) Writes the Byte Order Mark encoding identifier to the open file; the BOM should be written at the beginning of file
WriteBool (Boolean) Writes a Boolean value to the file and returns True if the operation finished correctly
WriteByte (Boolean) Writes a byte to file and returns True if the operation finished correctly
WriteBytes (Boolean) Writes n bytes to file and returns True if the operation finished correctly
WriteDouble (Boolean) Writes a Double value to the file and returns True if the operation finished correctly
WriteInt (Boolean) Writes an Integer value to the file and returns True if the operation finished correctly
WriteLine (Boolean) Writes a string to a file using a certain encoding
WriteLong (Boolean) Writes a Long value to the file and returns True if the operation finished correctly
WriteNumCharsAndString (Boolean) Write a string to a binary file
WriteUnicodeLine (Boolean) Writes an Unicode line to a file (with vbCrLf at the end)
WriteUTF8Line (Boolean) Writes a UTF8 string to a file (with vbCrLf at the end)
Remarks