File.Create Method (String, Int32)
Creates or overwrites the specified file.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.String
The name of the file.
- Type: System.Int32
The number of bytes buffered for reads and writes to the file.
The caller does not have the required permission.
path specified a file that is read-only.
path is a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
path is a null reference (Nothing in Visual Basic).
The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
The specified path is invalid (for example, it is on an unmapped drive).
An I/O error occurred while creating the file.
path is in an invalid format.
The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory. To obtain the current working directory, see GetCurrentDirectory.
This method is equivalent to the FileStream(String, FileMode, FileAccess, FileShare, Int32) constructor overload. If the specified file does not exist, it is created; if it does exist and it is not read-only, the contents are overwritten.
By default, full read/write access to new files is granted to all users. The file is opened with read/write access and must be closed before it can be opened by another application.
For a list of common I/O tasks, see Common I/O Tasks.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.