Various helper functions for the file system. More...
Static Public Member Functions | |
static bool | isUnixPath (string path) |
Checks if the given path is from a Unix-device More... | |
static bool | isWindowsPath (string path) |
Checks if the given path is from a Windows-device More... | |
static bool | isUNCPath (string path) |
Checks if the given path is UNC More... | |
static bool | isURL (string path) |
Checks if the given path is an URL More... | |
static string | ValidatePath (string path, bool addEndDelimiter=true, bool preserveFile=true, bool removeInvalidChars=true) |
Validates a given path and add missing slash. More... | |
static string | ValidateFile (string path, bool removeInvalidChars=true) |
Validates a given file. More... | |
static bool | HasPathInvalidChars (string path, bool ignoreNullOrEmpty=true) |
Checks a given path for invalid characters More... | |
static bool | HasFileInvalidChars (string file, bool ignoreNullOrEmpty=true) |
Checks a given file for invalid characters More... | |
static string[] | GetFilesForName (string path, bool isRecursive=false, params string[] filenames) |
Find files inside a path. More... | |
static string[] | GetFiles (string path, bool isRecursive=false, params string[] extensions) |
Find files inside a path. More... | |
static string[] | GetDirectories (string path, bool isRecursive=false) |
Find directories inside. More... | |
static string[] | GetDrives () |
Find all logical drives. More... | |
static bool | CopyDirectory (string sourceDir, string destDir, bool move=false, bool moveSafe=true) |
Copy or move a directory. More... | |
static bool | CopyFile (string sourceFile, string destFile, bool move=false, bool moveSafe=true) |
Copy or move a file. More... | |
static bool | MoveDirectory (string sourceDir, string destDir) |
Move a directory. More... | |
static bool | MoveFile (string sourceFile, string destFile) |
Move a file. More... | |
static string | RenameDirectory (string path, string newName) |
Renames a directory in a path. More... | |
static string | RenameFile (string path, string newName) |
Renames a file in a path. More... | |
static bool | DeleteFile (string file) |
Delete a file. More... | |
static bool | DeleteDirectory (string dir) |
Delete a directory. More... | |
static bool | ExistsFile (string file) |
Checks if the directory exists. More... | |
static bool | ExistsDirectory (string path) |
Checks if the directory exists. More... | |
static string | CreateDirectory (string path, string folderName) |
Creates a directory in a given path. More... | |
static bool | CreateDirectory (string path) |
Creates a directory. More... | |
static string | CreateFile (string path, string fileName) |
Creates a file in a given path. More... | |
static bool | CreateFile (string path) |
Creates a file. More... | |
static bool | isDirectory (string path, bool checkForExtensions=true) |
Checks if the path is a directory. More... | |
static bool | isFile (string path, bool checkForExtensions=true) |
Checks if the path is a file. More... | |
static bool | isRoot (string path) |
Checks if the path is the root. More... | |
static string | GetFileName (string path, bool removeInvalidChars=true) |
Returns the file name for the path. More... | |
static string | GetCurrentDirectoryName (string path) |
Returns the current directory name for the path. More... | |
static string | GetDirectoryName (string path) |
Returns the directory name for the path. More... | |
static long | GetFilesize (string path) |
Returns the size of a file. More... | |
static string | GetExtension (string path) |
Returns the extension of a file. More... | |
static System.DateTime | GetLastModifiedDate (string path) |
Returns the size of a file. More... | |
static string | ReadAllText (string sourceFile, System.Text.Encoding encoding=null) |
Reads the text of a file. More... | |
static string[] | ReadAllLines (string sourceFile, System.Text.Encoding encoding=null) |
Reads all lines of text from a file. More... | |
static byte[] | ReadAllBytes (string sourceFile) |
Reads the bytes of a file. More... | |
static bool | WriteAllText (string destFile, string text, System.Text.Encoding encoding=null) |
Writes text to a file. More... | |
static bool | WriteAllLines (string destFile, string[] lines, System.Text.Encoding encoding=null) |
Writes all lines of text to a file. More... | |
static bool | WriteAllBytes (string destFile, byte[] data) |
Writes bytes to a file. More... | |
static bool | ShowPath (string path) |
Shows the location of a path (or file) in OS file explorer. NOTE: only works on standalone platforms More... | |
static bool | ShowFile (string file) |
Shows the location of a file (or path) in OS file explorer. NOTE: only works on standalone platforms More... | |
static bool | OpenFile (string file) |
Opens a file with the OS default application. NOTE: only works for standalone platforms More... | |
static bool | PathHasInvalidChars (string path) |
Checks a given path for invalid characters More... | |
static bool | FileHasInvalidChars (string file) |
Checks a given file for invalid characters More... | |
static bool | CopyPath (string sourceDir, string destDir, bool move=false) |
Copy or move a directory. More... | |
static bool | MovePath (string sourceDir, string destDir) |
Move a directory. More... | |
Static Public Attributes | |
static string | ApplicationDataPath => _applicationDataPath |
Returns the Unity application data path. More... | |
static string | ApplicationTempPath => _applicationTempPath |
Returns the Unity application temporary path. More... | |
static string | ApplicationPersistentPath => _applicationPersistentPath |
Returns the Unity application persistent path. More... | |
static string | TempFile => System.IO.Path.GetTempFileName() |
Returns a temporary file. More... | |
static string | TempPath => System.IO.Path.GetTempPath() |
Returns the temporary directory path from the device. More... | |
Properties | |
static string | StreamingAssetsPath [get] |
Returns the path to the the "Streaming Assets". More... | |
Detailed Description
Various helper functions for the file system.
Member Function Documentation
◆ CopyDirectory()
|
static |
Copy or move a directory.
- Parameters
-
sourceDir Source directory path destDir Destination directory path move Move directory instead of copy (optional, default: false) moveSafe Moves a directory in a safe, but slower way (optional, default: true)
- Returns
- True if the operation was successful
◆ CopyFile()
|
static |
Copy or move a file.
- Parameters
-
sourceFile Source file path destFile Destination file path move Move file instead of copy (optional, default: false) moveSafe Moves a file in a safe, but slower way (optional, default: true)
- Returns
- True if the operation was successful
◆ CopyPath()
|
static |
Copy or move a directory.
- Parameters
-
sourceDir Source directory path destDir Destination directory path move Move directory instead of copy (optional, default: false)
- Returns
- True if the operation was successful
◆ CreateDirectory() [1/2]
|
static |
Creates a directory.
- Parameters
-
path Path to the directory to create
- Returns
- True if the operation was successful
◆ CreateDirectory() [2/2]
|
static |
Creates a directory in a given path.
- Parameters
-
path Path for the directory folderName New folder
◆ CreateFile() [1/2]
|
static |
Creates a file.
- Parameters
-
path Path to the file to create
- Returns
- True if the operation was successful
◆ CreateFile() [2/2]
|
static |
Creates a file in a given path.
- Parameters
-
path Path for the file fileName New file
◆ DeleteDirectory()
|
static |
Delete a directory.
- Parameters
-
dir Directory to delete
- Returns
- True if the operation was successful
◆ DeleteFile()
|
static |
Delete a file.
- Parameters
-
file File to delete
- Returns
- True if the operation was successful
◆ ExistsDirectory()
|
static |
Checks if the directory exists.
- Returns
- True if the directory exists
◆ ExistsFile()
|
static |
Checks if the directory exists.
- Returns
- True if the directory exists
◆ FileHasInvalidChars()
|
static |
Checks a given file for invalid characters
- Parameters
-
file File to check for invalid characters
- Returns
- Returns true if the file contains invalid chars, otherwise it's false.
◆ GetCurrentDirectoryName()
|
static |
Returns the current directory name for the path.
- Parameters
-
path Path to the directory
- Returns
- Current directory name for the path
◆ GetDirectories()
|
static |
Find directories inside.
- Parameters
-
path Path to find the directories isRecursive Recursive search (optional, default: false)
- Returns
- Returns array of the found directories inside the path. Zero length array when an error occured.
◆ GetDirectoryName()
|
static |
Returns the directory name for the path.
- Parameters
-
path Path to the directory
- Returns
- Directory name for the path
◆ GetDrives()
|
static |
Find all logical drives.
- Returns
- Returns array of the found drives. Zero length array when an error occured.
◆ GetExtension()
|
static |
Returns the extension of a file.
- Parameters
-
path Path to the file
- Returns
- Extension of the file
◆ GetFileName()
|
static |
Returns the file name for the path.
- Parameters
-
path Path to the file removeInvalidChars Removes invalid characters in the file name (optional, default: true)
- Returns
- File name for the path
◆ GetFiles()
|
static |
Find files inside a path.
- Parameters
-
path Path to find the files isRecursive Recursive search (optional, default: false) extensions Extensions for the file search, e.g. "png" (optional)
- Returns
- Returns array of the found files inside the path (alphabetically ordered). Zero length array when an error occured.
◆ GetFilesForName()
|
static |
Find files inside a path.
- Parameters
-
path Path to find the files isRecursive Recursive search (optional, default: false) filenames Array of file names for the file search, e.g. "Image.png" (optional)
- Returns
- Returns array of the found files inside the path (alphabetically ordered). Zero length array when an error occured.
◆ GetFilesize()
|
static |
Returns the size of a file.
- Parameters
-
path Path of the file
- Returns
- Size for the file
◆ GetLastModifiedDate()
|
static |
Returns the size of a file.
- Parameters
-
path Path to the file
- Returns
- Size for the file
◆ HasFileInvalidChars()
|
static |
Checks a given file for invalid characters
- Parameters
-
file File to check for invalid characters ignoreNullOrEmpty If set to true, return false for null or empty paths (optional, default: true)
- Returns
- Returns true if the file contains invalid chars, otherwise it's false.
◆ HasPathInvalidChars()
|
static |
Checks a given path for invalid characters
- Parameters
-
path Path to check for invalid characters ignoreNullOrEmpty If set to true, return false for null or empty paths (optional, default: true)
- Returns
- Returns true if the path contains invalid chars, otherwise it's false.
◆ isDirectory()
|
static |
Checks if the path is a directory.
- Parameters
-
path Path to the directory checkForExtensions Check for extensions (optional, default: true)
- Returns
- True if the path is a directory
◆ isFile()
|
static |
Checks if the path is a file.
- Parameters
-
path Path to the file checkForExtensions Check for extensions (optional, default: true)
- Returns
- True if the path is a file
◆ isRoot()
|
static |
Checks if the path is the root.
- Parameters
-
path Possible root
- Returns
- True if the path is the root
◆ isUNCPath()
|
static |
Checks if the given path is UNC
- Parameters
-
path Path to check
- Returns
- True if the given path is UNC
◆ isUnixPath()
|
static |
Checks if the given path is from a Unix-device
- Parameters
-
path Path to check
- Returns
- True if the given path is from a Unix-device
◆ isURL()
|
static |
Checks if the given path is an URL
- Parameters
-
path Path to check
- Returns
- True if the given path is an URL
◆ isWindowsPath()
|
static |
Checks if the given path is from a Windows-device
- Parameters
-
path Path to check
- Returns
- True if the given path is from a Windows-device
◆ MoveDirectory()
|
static |
Move a directory.
- Parameters
-
sourceDir Source directory path destDir Destination directory path
- Returns
- True if the operation was successful
◆ MoveFile()
|
static |
Move a file.
- Parameters
-
sourceFile Source file path destFile Destination file path
- Returns
- True if the operation was successful
◆ MovePath()
|
static |
Move a directory.
- Parameters
-
sourceDir Source directory path destDir Destination directory path
- Returns
- True if the operation was successful
◆ OpenFile()
|
static |
Opens a file with the OS default application. NOTE: only works for standalone platforms
- Parameters
-
file File path
- Returns
- True if the operation was successful
◆ PathHasInvalidChars()
|
static |
Checks a given path for invalid characters
- Parameters
-
path Path to check for invalid characters
- Returns
- Returns true if the path contains invalid chars, otherwise it's false.
◆ ReadAllBytes()
|
static |
Reads the bytes of a file.
- Parameters
-
sourceFile Source file path
- Returns
- Byte-content of the file
◆ ReadAllLines()
|
static |
Reads all lines of text from a file.
- Parameters
-
sourceFile Source file path encoding Encoding of the text (optional, default: UTF8)
- Returns
- Array of text lines from the file
◆ ReadAllText()
|
static |
Reads the text of a file.
- Parameters
-
sourceFile Source file path encoding Encoding of the text (optional, default: UTF8)
- Returns
- Text-content of the file
◆ RenameDirectory()
|
static |
Renames a directory in a path.
- Parameters
-
path Path to the directory newName New name for the directory
- Returns
- New path of the directory
◆ RenameFile()
|
static |
Renames a file in a path.
- Parameters
-
path Path to the file newName New name for the file
- Returns
- New path of the file
◆ ShowFile()
|
static |
Shows the location of a file (or path) in OS file explorer. NOTE: only works on standalone platforms
- Returns
- True if the operation was successful
◆ ShowPath()
|
static |
Shows the location of a path (or file) in OS file explorer. NOTE: only works on standalone platforms
- Returns
- True if the operation was successful
◆ ValidateFile()
|
static |
Validates a given file.
- Parameters
-
path File to validate removeInvalidChars Removes invalid characters in the file name (optional, default: true)
- Returns
- Valid file path
◆ ValidatePath()
|
static |
Validates a given path and add missing slash.
- Parameters
-
path Path to validate addEndDelimiter Add delimiter at the end of the path (optional, default: true) preserveFile Preserves a given file in the path (optional, default: true) removeInvalidChars Removes invalid characters in the path name (optional default: true)
- Returns
- Valid path
◆ WriteAllBytes()
|
static |
Writes bytes to a file.
- Parameters
-
destFile Destination file path data Byte-content to write
- Returns
- True if the operation was successful
◆ WriteAllLines()
|
static |
Writes all lines of text to a file.
- Parameters
-
destFile Destination file path lines Array of text lines to write encoding Encoding of the text (optional, default: UTF8)
- Returns
- True if the operation was successful
◆ WriteAllText()
|
static |
Writes text to a file.
- Parameters
-
destFile Destination file path text Text-content to write encoding Encoding of the text (optional, default: UTF8)
- Returns
- True if the operation was successful
Member Data Documentation
◆ ApplicationDataPath
|
static |
Returns the Unity application data path.
- Returns
- Unity application data path
◆ ApplicationPersistentPath
|
static |
Returns the Unity application persistent path.
- Returns
- Unity application persistent path
◆ ApplicationTempPath
|
static |
Returns the Unity application temporary path.
- Returns
- Unity application temporary path
◆ TempFile
|
static |
Returns a temporary file.
- Returns
- Temporary file
◆ TempPath
|
static |
Returns the temporary directory path from the device.
- Returns
- Temporary directory path of the device
Property Documentation
◆ StreamingAssetsPath
|
staticget |
Returns the path to the the "Streaming Assets".
- Returns
- The path to the the "Streaming Assets".
The documentation for this class was generated from the following file:
- C:/Users/slaub/Unity/assets/OnlineCheck/OnlineCheckPro/Assets/Plugins/crosstales/Common/Scripts/Util/FileHelper.cs