title
File Handling | Microsoft Docs
ms.custom
ms.date
11/04/2016
ms.reviewer
ms.suite
ms.technology
ms.tgt_pltfrm
ms.topic
article
f1_keywords
dev_langs
helpviewer_keywords
files [C++], handling
files [C++], opening
files [C++], manipulating
ms.assetid
48119e2e-e94f-4602-b08b-b72440f731d8
caps.latest.revision
17
author
corob-msft
ms.author
corob
manager
ghogen
translation.priority.ht
de-de
es-es
fr-fr
it-it
ja-jp
ko-kr
ru-ru
zh-cn
zh-tw
translation.priority.mt
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.
File-Handling Routines (File Descriptor)
These routines operate on files designated by a file descriptor.
File-Handling Routines (Path or Filename)
These routines operate on files specified by a path or filename.
Routine
Use
_access, _waccess , _access_s, _waccess_s
Check file-permission setting
_chmod, _wchmod
Change file-permission setting
_fullpath, _wfullpath
Expand a relative path to its absolute path name
_makepath, _wmakepath , _makepath_s, _wmakepath_s
Merge path components into single, full path
_mktemp, _wmktemp , _mktemp_s, _wmktemp_s
Create unique filename
remove, _wremove
Delete file
rename, _wrename
Rename file
_splitpath, _wsplitpath , _splitpath_s, _wsplitpath_s
Parse path into components
_stat, _stat64, _stati64, _wstat, _wstat64, _wstati64
Get file-status information on named file
_umask , _umask_s
Set default permission mask for new files created by program
_unlink, _wunlink
Delete file
File-Handling Routines (Open File)
These routines open files.
Routine
Use
fopen, _wfopen , fopen_s, _wfopen_s
Opens a file and returns a pointer to the open file.
_fsopen, _wfsopen
Open a stream with file sharing and returns a pointer to the open file.
_open, _wopen
Opens a file and returns a file descriptor to the opened file.
_sopen, _wsopen , _sopen_s, _wsopen_s
Open a file with file sharing and returns a file descriptor to the open file.
_pipe
Creates a pipe for reading and writing.
freopen, _wfreopen , freopen_s, _wfreopen_s
Reassign a file pointer.
These routines provide a way to change the representation of the file between a FILE structure, a file descriptor, and a Win32 file handle.
Routine
Use
_fdopen, _wfdopen
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.
_get_osfhandle
Return operating-system file handle associated with existing C run-time file descriptor
_open_osfhandle
Associates C run-time file descriptor with an existing operating-system file handle.
The following Win32 functions also open files and pipes:
Run-Time Routines by Category
Directory Control
System Calls