Class FileSupport
Represents the methods to support some operations over files.
Inheritance
Inherited Members
Namespace: Lucene.Net.Support.IO
Assembly: Lucene.Net.dll
Syntax
public static class FileSupport
Methods
| Improve this Doc View SourceCreateTempFile(String, String)
Creates a new empty file in a random subdirectory of System.IO.Path.GetTempPath, using the given prefix and suffix strings to generate its name.
Declaration
public static FileInfo CreateTempFile(string prefix, string suffix)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The prefix string to be used in generating the file's name; must be at least three characters long |
System.String | suffix | The suffix string to be used in generating the file's name; may be null, in which case a random suffix will be generated |
Returns
Type | Description |
---|---|
System.IO.FileInfo | A System.IO.FileInfo instance representing the temp file that was created. |
Remarks
If this method returns successfully then it is guaranteed that:
- The file denoted by the returned abstract pathname did not exist before this method was invoked, and
- Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.
The prefix argument must be at least three characters long. It is recommended that the prefix be a short, meaningful string such as "hjb" or "mail".
The suffix argument may be null, in which case a random suffix will be used.
Both prefix and suffix must be provided with valid characters for the underlying system, as specified by System.IO.Path.GetInvalidFileNameChars.
If the directory argument is null then the system-dependent default temporary-file directory will be used, with a random subdirectory name. The default temporary-file directory is specified by the System.IO.Path.GetTempPath method. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "C:\Users\[UserName]\AppData\Local\Temp".
CreateTempFile(String, String, DirectoryInfo)
Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.
Declaration
public static FileInfo CreateTempFile(string prefix, string suffix, DirectoryInfo directory)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The prefix string to be used in generating the file's name; must be at least three characters long |
System.String | suffix | The suffix string to be used in generating the file's name; may be null, in which case a random suffix will be generated |
System.IO.DirectoryInfo | directory | The directory in which the file is to be created, or null if the default temporary-file directory is to be used |
Returns
Type | Description |
---|---|
System.IO.FileInfo | A System.IO.FileInfo instance representing the temp file that was created. |
Remarks
If this method returns successfully then it is guaranteed that:
- The file denoted by the returned abstract pathname did not exist before this method was invoked, and
- Neither this method nor any of its variants will return the same abstract pathname again in the current invocation of the virtual machine.
The prefix argument must be at least three characters long. It is recommended that the prefix be a short, meaningful string such as "hjb" or "mail".
The suffix argument may be null, in which case a random suffix will be used.
Both prefix and suffix must be provided with valid characters for the underlying system, as specified by System.IO.Path.GetInvalidFileNameChars.
If the directory argument is null then the system-dependent default temporary-file directory will be used, with a random subdirectory name. The default temporary-file directory is specified by the System.IO.Path.GetTempPath method. On UNIX systems the default value of this property is typically "/tmp" or "/var/tmp"; on Microsoft Windows systems it is typically "C:\Users\[UserName]\AppData\Local\Temp".
GetCanonicalPath(FileSystemInfo)
Returns the absolute path of this System.IO.FileSystemInfo with all references resolved and any drive letters normalized to upper case on Windows. An absolute path is one that begins at the root of the file system. The canonical path is one in which all references have been resolved. For the cases of '..' and '.', where the file system supports parent and working directory respectively, these are removed and replaced with a direct directory reference.
Declaration
public static string GetCanonicalPath(this FileSystemInfo path)
Parameters
Type | Name | Description |
---|---|---|
System.IO.FileSystemInfo | path | This System.IO.FileSystemInfo instance. |
Returns
Type | Description |
---|---|
System.String | The canonical path of this file. |