Class FileSupport
Represents the methods to support some operations over files.
Inheritance
Namespace: Lucene.Net.Support.IO
Assembly: Lucene.Net.dll
Syntax
public static class FileSupport : object
Methods
| Improve this Doc View SourceCreateTempFile(String, String)
Creates a new empty file in a random subdirectory of
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 |
---|---|
FileInfo | A |
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
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
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 |
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 |
---|---|
FileInfo | A |
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
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
GetCanonicalPath(FileSystemInfo)
Returns the absolute path of this
Declaration
public static string GetCanonicalPath(this FileSystemInfo path)
Parameters
Type | Name | Description |
---|---|---|
FileSystemInfo | path | This |
Returns
Type | Description |
---|---|
System.String | The canonical path of this file. |
IsFileAlreadyExistsException(Exception, String)
Tests whether the passed in
Declaration
public static bool IsFileAlreadyExistsException(Exception ex, string filePath)
Parameters
Type | Name | Description |
---|---|---|
Exception | ex | An exception, for comparison. |
System.String | filePath | The path of the file to check. This is used as a fallback in case the current OS doesn't have an HResult (an edge case). |
Returns
Type | Description |
---|---|
System.Boolean |
|