0

My file is located in C:\\Input\\pStep.p21 . i want to open that file in my cpp program. How can i do it? I am using char* inputPath="C:\\Input\\pStep.p21"; but its not finding my file in program. How to get current working directory in VC++?. Its working if try to save p21 file but failing if i read it.

my code in CAA:

#include<CATSDM_Services>
#include<SdaiModel.h>
#include<CATIUniCodeString>
---
---

main()
{
CATIUniCodeString inputPath("C:\\Input\\pStep.p21");
HRESULT hr=S_OK;
SdaiModel edxModel=Null;
//this method reads express schema name, input p21 file and sdaimodel
 hr=CreateModelFromFile(inputPath,"parts",edxModel);
if(FAILED(hr))
{
cout<<"Model created succesfully";
}
else
{
cout<<"Failed";
}
}
2
  • It's not located in C:\\Input\\input.txt (although that's how you need to use it in C/C++. How are you trying to open it? What does "not finding my file in program" mean? Please edit your question and add more specifics, including the code you are using to try and open it and what "not findinng my file in program" means. Thanks.
    – Ken White
    Nov 30, 2011 at 17:45
  • Not even that only method , all the methods that related to importing a p21 file to sdaimodel are generating the same error. Am i missing something..Creating a fresh model working file with the same schema(parts) what i used above. But when it comes to importing an existing data(p21 file) its bugging me a lot. Dec 1, 2011 at 9:55

1 Answer 1

0

Sorry for not seeing the question earlier.

From what I am seeing in your code, the test is wrong. The FAILED() macro denotes incorrect execution. Thus from you code, if you see "Failed" on the console, it actually means the execution of the method ran OK.

Change your code to something like:

if ( SUCCEEDED(hr) )
{
    cout<<"Model created succesfully";
}
else
{
    cout<<"Failed";
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.