Method CreateTempFile
CreateTempFile(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