How to make a file action: obtain the file name: Open the file: mobile file pointer .........

zhaozj2021-02-11  208

File name

{

Cstring

Filepathname;

CFiledialog DLG (TRUE); /// true is the Open dialog, FALSE is the Save AS dialog

IF (DLG.Domodal () == iDOK)

Filepathname = dlg.getpathname ();

}

Related information: cfiledialog is used to take several member functions of the text name:

If the selected file is C: /Windows/test.exe

then:

(1) getPathname (); Take full name, including the full path. Retrieve C: /Windows/test.exe

(2) getFileTitle (); Take a full name: Test.exe

(3) getFileName (); retrieved TEST

(4) getfileext (); take the extension EXE to open the file

Cfile file ("c: / Hello.txt", cfile :: modeRead; /// read-only mode open

/// cfile :: ModeRead can be changed to CFile :: Modewrite (written), CFile :: ModeReadwrite (Reading), CFILE :: MODECREATE (New)

example:

{

CFILE FILE;

File.Open ("C: / Hello.txt", CFile :: ModeCreate | CFILE :: ModeWrite;

...

...

} Mobile file pointer

File.seek (100, cfile :: begin); /// From the file header to move 100 bytes

File.seek (-50, cfile :: end); // move from 50 bytes from the end of the file

File.seek (-30, cfile :: current); // - move 30 bytes from the current location

File.seektobegin (); /// Move to the file header

File.seektoend (); /// Move to the file end read and write files

Read the file:

Char buffer [1000];

File.read (Buffer, 1000);

Write files:

CString String ("This world is only paranoid can succeed");

File.write (string, 8); close the file

File.Close ();

转载请注明原文地址:https://www.9cbs.com/read-3898.html

New Post(0)