VC有没有建立和删除文件的库函数可用?知道的兄弟给个实例,先谢了......没有函数,有核心语句也可以啊,最好能给个实例.十万火急!!!!!!!!!!

解决方案 »

  1.   

    The OpenFile function creates, opens, reopens, or deletes a file. Note  This function is provided only for compatibility with 16-bit versions of Windows. Win32-based applications should use the CreateFile function. HFILE OpenFile(
      LPCSTR lpFileName,        // file name
      LPOFSTRUCT lpReOpenBuff,  // file information
      UINT uStyle               // action and attributes
    );
    Parameters
    lpFileName 
    [in] Pointer to a null-terminated string that names the file to be opened. The string must consist of characters from the Windows 3.x character set. The OpenFile function does not support Unicode file names. Also, OpenFile does not support opening named pipes. 
    lpReOpenBuff 
    [out] Pointer to the OFSTRUCT structure that receives information about the file when it is first opened. The structure can be used in subsequent calls to the OpenFile function to refer to the open file. 
    The OFSTRUCT structure contains a pathname string member whose length is limited to OFS_MAXPATHNAME characters. OFS_MAXPATHNAME is currently defined to be 128. Because of this, you cannot use the OpenFile function to open a file whose path length exceeds 128 characters. The CreateFile function does not have such a path length limitation. uStyle 
    [in] Specifies the action to take. This parameter can be one or more of the following values. Value Meaning 
    OF_CANCEL Ignored. In the Win32 API, OF_PROMPT produces a dialog box containing a Cancel button. 
    OF_CREATE Creates a new file. If the file already exists, it is truncated to zero length. 
    OF_DELETE Deletes the file. 
    OF_EXIST Opens the file and then closes it. Used to test for a file's existence. 
    OF_PARSE Fills the OFSTRUCT structure but carries out no other action. 
    OF_PROMPT Displays a dialog box if the requested file does not exist. The dialog box informs the user that the system cannot find the file, and it contains Retry and Cancel buttons. Choosing the Cancel button directs OpenFile to return a file-not-found error message. 
    OF_READ Opens the file for reading only. 
    OF_READWRITE Opens the file for reading and writing. 
    OF_REOPEN Opens the file using information in the reopen buffer. 
    OF_SHARE_COMPAT For MS-DOS–based file systems using the Win32 API, opens the file with compatibility mode, allowing any process on a specified computer to open the file any number of times. Other efforts to open with any other sharing mode fail. 
    Windows NT/2000: This flag is mapped to the CreateFile function's FILE_SHARE_READ | FILE_SHARE_WRITE flags.
     
    OF_SHARE_DENY_NONE Opens the file without denying read or write access to other processes. On MS-DOS-based file systems using the Win32 API, if the file has been opened in compatibility mode by any other process, the function fails. 
    Windows NT/2000: This flag is mapped to the CreateFile function's FILE_SHARE_READ | FILE_SHARE_WRITE flags.
     
    OF_SHARE_DENY_READ Opens the file and denies read access to other processes. On MS-DOS-based file systems using the Win32 API, if the file has been opened in compatibility mode or for read access by any other process, the function fails. 
    Windows NT/2000: This flag is mapped to the CreateFile function's FILE_SHARE_WRITE flag.
     
    OF_SHARE_DENY_WRITE Opens the file and denies write access to other processes. On MS-DOS-based file systems using the Win32 API, if the file has been opened in compatibility mode or for write access by any other process, the function fails. 
    Windows NT/2000: This flag is mapped to the CreateFile function's FILE_SHARE_READ flag.
     
    OF_SHARE_EXCLUSIVE Opens the file with exclusive mode, denying both read and write access to other processes. If the file has been opened in any other mode for read or write access, even by the current process, the function fails. 
    OF_VERIFY Verifies that the date and time of the file are the same as when it was previously opened. This is useful as an extra check for read-only files. 
    OF_WRITE Opens the file for writing only. 
    Return Values
    If the function succeeds, the return value specifies a file handle.If the function fails, the return value is HFILE_ERROR. To get extended error information, call GetLastError. Res
    If the lpFileName parameter specifies a file name and extension only, this function searches for a matching file in the following directories, in the order shown: The directory from which the application loaded. 
    The current directory. 
    Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory. 
    Windows NT/2000: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32. Windows NT/2000: The 16-bit Windows system directory. There is no Win32 function that retrieves the path of this directory, but it is searched. The name of this directory is SYSTEM. 
    The Windows directory. Use the GetWindowsDirectory function to get the path of this directory. 
    The directories that are listed in the PATH environment variable. 
    The lpFileName parameter cannot contain wildcard characters.The 32-bit OpenFile function does not support the OF_SEARCH flag supported by the 16-bit Windows OpenFile function. The OF_SEARCH flag directs the system to search for a matching file even when the file name includes a full path. To search for a file in a Win32-based application, use the SearchPath function.To close the file after use, call the _lclose function. 
      

  2.   

    DeleteFile
    This function deletes an existing file from a file system. It can also delete an unmounted database volume. A remote application interface (RAPI) version of this function exists, and it is named CeDeleteFile. BOOL DeleteFile(
    LPCTSTR lpFileName ); 
    Parameters
    lpFileName 
    [in] Pointer to a null-terminated string that specifies the file or database volume to be deleted. 
    Return Values
    Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.Res
    If an application attempts to delete a file that does not exist, the DeleteFile function fails. Use the RemoveDirectory function to delete a directory.The DeleteFile function fails if an application attempts to delete a file that is open for normal I/O or as a memory-mapped file.To close an open file handle, use the CloseHandle function. To unmount a database volume, use the CeUnmountDBVol function.
      

  3.   

    HFILE OpenFile(
      LPCSTR lpFileName,
      LPOFSTRUCT lpReOpenBuff,
      UINT uStyle
    );
    uStyle选择OF_DELETE时,删除文件
      

  4.   

    re:freeheart1977
    请问如何用shell实现,我是刚接触C++
      

  5.   

    OFSTRUCT of;
    OpenFile("f:\\a.txt", &of, OF_DELETE);