Export (0) Print
Expand All

File Handling

Use these routines to create, delete, and manipulate files and to set and check file-access permissions.

The C run-time libraries have a 512 limit for the number of files that can be open at any one time. Attempting to open more than the maximum number of file descriptors or file streams causes program failure. Use _setmaxstdio to change this number.

The following routines operate on files designated by a file descriptor.

File-Handling Routines (File Descriptor)

Routine Use
_chsize Change file size
_filelength Get file length
_fstat, _fstat64 _fstati64 Get file-status information on descriptor
_isatty Check for character device
_locking Lock areas of file
_setmode Set file-translation mode

The following routines operate on files specified by a path or filename.

File-Handling Routines (Path or Filename)

Routine Use
_access, _waccess Check file-permission setting
_chmod, _wchmod Change file-permission setting
_fullpath, _wfullpath Expand a relative path to its absolute path name
_get_osfhandle Return operating-system file handle associated with existing stream FILE pointer
_makepath, _wmakepath Merge path components into single, full path
_mktemp, _wmktemp Create unique filename
_open_osfhandle Associate C run-time file descriptor with existing operating-system file handle
remove, _wremove Delete file
rename, _wrename Rename file
_splitpath, _wsplitpath Parse path into components
_stat, _stat64, _stati64, _wstat, _wstat64, _wstati64 Get file-status information on named file
_umask Set default permission mask for new files created by program
_unlink, _wunlink Delete file

The following routines open files.

File-Handling Routines (Open File)

Routine Use
fopen Opens a file and returns a pointer to the open file.
_fsopen Open a stream with file sharing and returns a pointer to the open file.
_open Opens a file and returns a file descriptor to the opened file.
_sopen Open a file with file sharing and returns a file descriptor to the open file.
_fdopen Associates a stream with a file that was previously opened for low-level I/O and returns a pointer to the open stream.
_fileno Gets the file descriptor associated with a stream.
_open_osfhandle Associates C run-time file descriptor with an existing operating-system file handle.
_pipe Creates a pipe for reading and writing.
freopen Reassign a file pointer.

The following Win32 functions also open files and pipes:

  • CreateFile
  • CreatePipe
  • CreateNamedPipe

See Also

Run-Time Routines by Category | Run-Time Routines and .NET Framework Equivalents

Show:
© 2014 Microsoft