檔案處理

使用這些常式來建立、 刪除及管理檔案,以及設定和檢查檔案存取權限。

C 執行階段程式庫有 512 限制一次可開啟的檔案數目。 嘗試開啟一個以上的檔案描述項或檔案資料流的最大數目會造成程式失敗。 使用 _setmaxstdio 若要變更這個數字。

下列的常式操作檔案描述項所指定的檔案。

檔案處理常式 (在 [檔案描述元中)

常式

使用

.NET Framework 的對等用法

_chsize,_chsize_s

變更檔案的大小

System::IO::Stream::SetLengthSystem::IO::FileStream::SetLength

_filelength _filelengthi64

取得檔案長度

System::IO::Stream::LengthSystem::IO::FileStream::Length

_fstat、 _fstat32、 _fstat64、 _fstati64、 _fstat32i64、 _fstat64i32

取得描述元中的檔案狀態資訊

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

_get_osfhandle

現有的 c 執行階段檔案描述項相關聯的退款的作業系統檔案控制代碼

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

_isatty

檢查有視訊文字裝置

System::IO::Stream::CanWriteSystem::IO::FileStream::CanWrite

_locking

鎖定的檔案的區域

System::IO::FileStream::Lock

_open_osfhandle

C 執行階段檔案描述項關聯現有的作業系統檔案控制代碼

System::IO::FileStream::Handle

_setmode

設定檔案轉譯模式

System::IO::BinaryReader 類別System::IO::TextReader 類別

下列的常式會針對指定的路徑或檔名的檔案作業。

檔案處理常式 (路徑或檔名)

常式

使用

.NET Framework 的對等用法

_access _waccess, _access_s _waccess_s

請檢查檔案權限設定

System::IO::FileAccess 列舉型別

_chmod _wchmod

變更檔案使用權限設定

System::IO::File::SetAttributesSystem::Security::Permissions::FileIOPermission

_fullpath _wfullpath

展開相對的路徑為絕對路徑名稱

System::IO::File:: 建立

_makepath _wmakepath, _makepath_s _wmakepath_s

路徑元件合併成單一、 完整的路徑

System::IO::File:: 建立

_mktemp,_wmktemp_mktemp_s _wmktemp_s

建立唯一的檔名

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

移除 _wremove

刪除檔案

System::IO::File::Delete

rename] _wrename

重新命名檔案

System::IO::File::Move

_splitpath,_wsplitpath_splitpath_s _wsplitpath_s

剖析成元件的路徑

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

_stat、 _stat64、 _stati64、 _wstat、 _wstat64、 _wstati64

取得已命名的檔案上的檔案狀態資訊

System::IO::File::GetAttributesSystem::IO::File::GetCreationTimeSystem::IO::File::GetLastAccessTimeSystem::IO::File::GetLastWriteTime

_umask, _umask_s

設定由程式所建立的新檔案的預設權限遮罩

System::IO::File::SetAttributes

_unlink _wunlink

刪除檔案

System::IO::File::Delete

下列的常式開啟檔案。

檔案處理常式 (開啟的檔案)

常式

使用

.NET Framework 的對等用法

fopen _wfopen, fopen_s _wfopen_s

開啟檔案,並傳回開啟檔案的指標。

System::IO::File::Open, System::IO::FileStream::FileStream

_fsopen _wfsopen

開啟資料流與檔案共用,並返回開啟的檔案中的指標。

System::IO::File::Open, System::IO::FileStream::FileStream

_open _wopen

開啟檔案,並返回開啟的檔案中的檔案描述項。

System::IO::File::Open, System::IO::FileStream::FileStream

_sopen _wsopen, _sopen_s _wsopen_s

使用檔案共用來開啟檔案,並返回開啟的檔案中的檔案描述項。

 

_pipe

建立用於讀取和寫入管道。

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

freopen _wfreopen, freopen_s _wfreopen_s

重新指派檔案指標。

System::IO::File::Open, System::IO::FileStream::FileStream

下列函式提供一個方法來變更檔案之間的表示方法FILE結構、 檔案描述項和 Win32 檔案控制代碼。

_fdopen _wfdopen

會將資料流關聯的檔案,先前開啟的低階 I/O,並返回開啟的資料流的指標。

System::IO::FileStream::FileStream

_fileno

取得與資料流相關的檔案描述項。

System::IO::FileStream::Handle

_get_osfhandle

現有的 c 執行階段檔案描述項相關聯的退款的作業系統檔案控制代碼

不適用。 若要呼叫標準的 c 函式,使用PInvoke。 如需詳細資訊,請參閱平台叫用範例

_open_osfhandle

C 執行階段檔案描述項關聯現有的作業系統檔案控制代碼。

System::IO::FileStream::Handle

下列的 Win32 函式也會開啟檔案及管道:

請參閱

參考

依類別的執行階段常式

目錄控制項

系統呼叫