• Forum
  • Jobs
  • File import with directory from user?

 
File import with directory from user?


Dear Supervisors and users,

I am not familiar with C++ and i face the following problem.

First i would like to tell you that i am working with other library called opencascade, okey well that is not a problem.

I use the following code to import my igs file. It works well.
But I am changing the file directory always in the source file which is inconvenient. I better to define it from output window. So that the user can define the directory after compiling the program. But i couldn't make that!

Here is my program (it works)
1
2
3
4
std::string filename = "/home/de052/Desktop/cd/original/KCS_simman.igs";
    	IGESControl_Controller::Init();
    	IGESControl_Reader reader;
    	IFSelect_ReturnStatus stat = reader.ReadFile(filename.c_str());


I want like
1
2
3
4
5
6
cout<< "Enter the directory of your file";
cin>> Director;
cout<< "Enter the file name"
cin>> Filename;

// then the above code continue to read the file in mentioned directory. 


It is also okey to combine the director and filename.

I thought this a better place as i couldn't find on Opencascade forum

Your help is much appreciated

Game

Why posting in the jobs section? Do you want to pay someone?

Anyway, what is the problem you encounter in doing that?
wrong forum, maybe a mod can move it but if I was you I'd delete it and make a new post.

To discuss your question, you can take the path/filename from the command line, or you can ask for it once you start the program. Personally I like getting it from the command line when you run the program.

The biggest problem that I can think of is if the path/filename has spaces. So you would wrap the path/filename string in "".

If your paying I'll do it cheap. send me a msg.
Hi.., Its better, Use INI file instead of using "cout" as below.

In ini file:
------------

[FILENAME]
FILE = ur file path;
[ENDS]


In CPP file:
--------------
string szFileName;
GetPrivateProfileString("FILENAME","FILE ","",szFileName,1000,"C:\\WINDOWS\\UrIniFileName.ini");


Then your code fallows..

Note: To change file name, first change ini file, then run the tool.
Topic archived. No new replies allowed.