Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

freopen (msvcrt)
 
.
Summary
freopen tries to close any file already associated with the stream given as third parameter and disassociates it. Then, whether that stream was successfuly closed or not, freopen opens the file whose name is passed in the first parameter, filename, and associates it with the specified stream just as fopen would do using the mode value specified as the second parameter.

C# Signature:

[DllImport("msvcrt.dll", SetLastError=true)]
static extern TODO freopen(TODO);

VB Signature:

Declare Function freopen Lib "msvcrt.dll" (ByVal filename As String, ByVal mode As String, ByVal stream As IntPtr) As IntPtr

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Mode can be any of the following:

  • "r" - Open a file for reading. The file must exist.
  • "w" - Create an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
  • "a" - Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.
  • "r+" - Open a file for update both reading and writing. The file must exist.
  • "w+" - Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
  • "a+" - Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

Documentation
freopen on MSDN

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions