|
Programming Reference for VirtualLab Fusion
2026.1
|
This class is subject to change. Programs using this class may require changes with a new version of VirtualLab.
Static class to support access to the file system and handling of file names.
More...
Static Public Member Functions | |
| static string | AddExtension (string fileName, string extension) |
| Adds an extension to the given file name. | |
| static void | CopyDirectory (string sourceDir, string destinationDir, bool recursive, bool overwrite) |
| Copies all files from the given source directory to the destination directory. | |
| static string | CreateTemporaryFileName (string path, string extension) |
| Creates a unique random file name with the given path and extension. | |
| static string | CreateTemporarySubDirectory () |
| Creates a new sub-directory in the version specific ApplicationSpecificTemporaryDirectory. | |
| static void | DeleteFileIfEmpty (string? filePath) |
| Deletes the given file if it is empty (i.e. has a length of zero bytes). | |
| static void | DeleteTempDir () |
| Deletes the main temp dir. | |
| static void | EnsureThatDirectoryExists (string path, bool containsFileName=false) |
| Ensures that the given directory exists. | |
| static string[] | GetFilesFromDirectory (string directory, string searchPattern="*", bool excludeBackupFiles=false, bool includeSubDirectories=true) |
| Wrapper around the Directory.GetFiles method with the following changes: • It is optionally searched recursively in all sub-directories. • Inaccessible files are ignored (.Net 8 only). • You can optionally exclude backup files created by the MoveToBackupFile(string, string) method. | |
| static string | GetSpecialFolder (Environment.SpecialFolder specialFolder, bool createVersionSpecificSubfolder) |
| Gets the specified special folder to which company and product name have been added as subdirectories. For example "c:\Users\{user}\AppData\Roaming\Wyrowski Photonics GmbH\VirtualLab Fusion\" is returned for
"Environment.SpecialFolder.ApplicationData". | |
| static bool | IsDirectoryEmpty (string path) |
| Checks whether the given directory is empty. | |
| static void | MoveToBackupFile (string fileName, string description="") |
| Moves a (faulty) file to a backup file, whereas already existing backup files are not overwritten. | |
| static void | RecursiveDelete (DirectoryInfo directoryToDelete) |
| Deletes the given directory and all its sub-directories. If there are files in the directory which have the read-only attribute or cannot be deleted because they are still in use or due to lacking access rights, the normal Directory.Delete just throws an exception and many files are not deleted. | |
Properties | |
| static string | ApplicationSpecificTemporaryDirectory [get] |
| Gets the application and version specific temporary directory as sub-directory of TemporaryDirectory. | |
| static string | ClipboardDirectory [get] |
| Temporary folder where files are stored which are passed around like with the Windows™ Clipboard. | |
| static string | ExecutableDirectory [get] |
| Gets the directory where the main executable of the application is located. | |
| static string | ProgramDataDirectoryCurrentVersion [get] |
| Gets and sets the directory where data from LightTrans or Wyrowski Photonics is stored for the current user. For example catalogs, detector add-ons, …. Every user has its own program data directory because "standard users" (without administrator privileges) cannot update into the normal program data directory. | |
| static string | TemporaryDirectory [get, set] |
| Temporary directory to save temporary data during calculations. | |
| static string | UserDataDirectory [get, set] |
This class is subject to change. Programs using this class may require changes with a new version of VirtualLab.
Static class to support access to the file system and handling of file names.
|
static |
Adds an extension to the given file name.
| fileName | The file name. |
| extension | The extension. |
|
static |
Copies all files from the given source directory to the destination directory.
| sourceDir | The source directory. |
| destinationDir | The destination directory. |
| recursive | If set to true, also the content of all sub-directories is copied. |
| overwrite | If set to true existing files are overwritten, even if they are read-only. |
| DirectoryNotFoundException | Source directory not found. |
|
static |
Creates a unique random file name with the given path and extension.
| path | Path in which uniqueness with the file name is ensured. |
| extension | The file extension (e.g. ".mtr") appended to the file name. |
|
static |
Creates a new sub-directory in the version specific ApplicationSpecificTemporaryDirectory.
|
static |
Deletes the given file if it is empty (i.e. has a length of zero bytes).
| filePath | The complete path of the file. |
|
static |
Ensures that the given directory exists.
| path | The path to check. |
| containsFileName | If this optional parameter is set to true it is assumed that the path contains a file name (which is removed prior to the check. |
|
static |
Wrapper around the Directory.GetFiles method with the following changes:
• It is optionally searched recursively in all sub-directories.
• Inaccessible files are ignored (.Net 8 only).
• You can optionally exclude backup files created by the MoveToBackupFile(string, string) method.
| directory | The relative or absolute path to the directory to search. This string is not case-sensitive. |
| searchPattern | Optional search pattern. Only file names containing this pattern are included in the result. |
| excludeBackupFiles | If this optional parameter is set to true backup files created by the MoveToBackupFile(string, string) or the GetBinaryBackupFileName(string) method are excluded. |
| includeSubDirectories | If this optional parameter is set to false, only the given directory is searched. Else also all sub-directories are searched. |
|
static |
Gets the specified special folder to which company and product name have been added as subdirectories. For example "c:\Users\{user}\AppData\Roaming\Wyrowski Photonics GmbH\VirtualLab Fusion\" is returned for "Environment.SpecialFolder.ApplicationData".
| specialFolder | Enumeration entry specifying the special folder. |
| createVersionSpecificSubfolder | If set to true a version specific sub-folder is created (e.g. "2024.1"). |
|
static |
Checks whether the given directory is empty.
| path | The path to the directory. |
True if the specified directory is empty.
|
static |
Moves a (faulty) file to a backup file, whereas already existing backup files are not overwritten.
| fileName | Name of the file. |
| description | The description for the error message. Must end with a period. E.g. "File could not be read." If this optional parameter is not specified, no error message is put out. |
|
static |
Deletes the given directory and all its sub-directories. If there are files in the directory which have the read-only attribute or cannot be deleted because they are still in use or due to lacking access rights, the normal Directory.Delete just throws an exception and many files are not deleted.
| directoryToDelete | The directory to delete. |
|
staticgetset |
Directory containing all user-defined catalogs and log files. </summary>