+ 4

How can I get the name of a file I want to open?

I have a Matrix class and I overloaded the operator << for fstream writing and >> for fstream reading... Now, I use a custom data type .mrx for saving the matrix for reading and writing. Since this type is a text based data type, I can alter it using notepad... Now, I recently encountered a Software, Default Programs Editor, which helps bind custom programs to run a file type, and I tried creating a program for that type along with options of editing... (This may help me learn how notepad, etc work) But, I am unable to determine the file name during runtime so that I can open it for editing using open(). So, how can I get the name in a string for editing? Shall I ask the user to input the name? //But how does notepad does the same thing without inputs?

13th May 2017, 9:41 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
6 ответов
+ 4
A good description of your problem Bro because one can easily understand and solve the problem only when the other guy explains it perfectly as you've did.
13th May 2017, 9:49 AM
Vishnu ks
Vishnu ks - avatar
+ 4
@vishnu ks I always give such explanations... But I don't receive many answers... This, is the irony - The people who don't explain their questions get answers on what is your question, and thus automatically start following the thread... But questions which are more explained receive few answers... BTW - Please provide an answer to my question...
13th May 2017, 9:56 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
There may exist multiple files of the particular extension. So a permanent name is not an option for me. Also, I wish to get the name of a file like the notepad gets it when we open a .txt file, and It doesn't have any user input taken for getting the name; All I wish to do is create instances of seperate exe files, each able to manipulate the data of a particular .mrx file it is linked to. This link is what I am able to make using the Default Programs Editor. Please give me a way so that I can redefine the file name in different instances. A user input, though looking to me as the only way possible, will defeat the idea of linking to .mrx files for editing like notepad.
13th May 2017, 11:51 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 3
ah, I understand now, rather than choosing a file to edit when you open your program you want the program to launch after clicking on the mrx file you wish to edit. edit: does this help? http://stackoverflow.com/questions/9115574/how-can-you-open-a-file-with-the-program-associated-with-its-file-extension
13th May 2017, 10:59 PM
Daemo
Daemo - avatar
+ 2
@Daemo Ill try this,but the ShellExecute Command is also requiring the file name... BTW Thank You!
14th May 2017, 4:20 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
a user input would be the best way if the name of the file changes. you could hardcore the name if you are sure it will always have the same path/name
13th May 2017, 10:35 AM
Daemo
Daemo - avatar