Home > Software engineering >  How to judge whether a file which is read when open the file
How to judge whether a file which is read when open the file

Time:10-11

Now have 3 files, using the three buttons on the interface open, respectively, to read files and data, according to the file open is using the open file dialog box, and there is a button is to rewrite the data just open the file, now the problem is how to determine which file to read files when I open it? So I corresponds to modify the data, give advice or comments please, best can shows the code, thank you!

CodePudding user response:

In front of the file read there must be an open file, open the action must know the path of the file to open, so at the time of opening, to know which is the file to read and write files

CodePudding user response:

CFile: : GetFilePath

Obtaining a File Name From a File Handle

CodePudding user response:

reference 1st floor lx624909677 response:
before the file read there must be an open file, open the action must know the path of the file to open, so at the time of opening, to know to read and write files which is the

You mean the file path? I am in the open dialog box to open the file, how to distinguish the three files?

CodePudding user response:

refer to the second floor zgl7903 response:
CFile: : GetFilePath

Obtaining a File Name From a File Handle

Can say about it

CodePudding user response:

reference zzj010 reply: 3/f
Quote: refer to 1st floor lx624909677 response:

In front of the file read there must be an open file, open the action must know the path of the file to open, so at the time of opening, to know to read and write files which is the

You mean the file path? I am in the open dialog box to open the file, how to distinguish the three files?

Three documents is a choice? Before directly file reading and writing, be sure to have the operation of a file object, this object is an object corresponding to a file, if it is selected a file, every time after click ok, then, will return you choose the path of the files

CodePudding user response:

reference 5 floor lx624909677 reply:
Quote: refer to the third floor zzj010 response:

Quote: refer to 1st floor lx624909677 response:

In front of the file read there must be an open file, open the action must know the path of the file to open, so at the time of opening, to know to read and write files which is the

You mean the file path? I am in the open dialog box to open the file, how to distinguish the three files?

Three documents is a choice? Before directly file reading and writing, be sure to have the operation of a file object, this object is an object corresponding to a file, if it is selected a file, every time after click ok, then, will return you choose the path of the files

No return ah, I'm used to open the file open dialog box

CodePudding user response:

CFileDialog DLG (true);
If (DLG) DoModal ()==IDOK)
{
Cstrings fileName=DLG. GetPathName ();//select the file name of the
.
}

CodePudding user response:

refer to 7th floor zgl7903 response:
CFileDialog DLG (true);
If (DLG) DoModal ()==IDOK)
{
Cstrings fileName=DLG. GetPathName ();//select the file name of the
.
}

This is the way the file open dialog box, you now that I write files button is not way to open file dialog box to open the file path, how should I get?

CodePudding user response:

If you want to open the file and application related words, can use the GetModuleFileName for current application file (containing the full path), which can construct an absolute path

CodePudding user response:

references 9 f zgl7903 response:
if you want to open the file and application related words, can use the GetModuleFileName for current application file (containing the full path), which can construct a absolute path

By the way, I am to judge which is recently opened files, and then you can rewrite the data to its, so with what method can determine which file I recently opened?

CodePudding user response:

http://www.nirsoft.net/utils/opened_files_view.html

CodePudding user response:

When you open the file name and the file pointer or a handle to a Key - Value into a map or a custom structure struct {cstrings strName, CFile * pFile}, manipulate the file you want to know what is the file name, and then went to get a pointer
  • Related