Skip to main content
November 5, 2009
Answered

How can we get the file path of the current document?

  • November 5, 2009
  • 1 reply
  • 11389 views

Hi,

     I want to store the current document file path into a string, I tried the  AIDocumentSuite, and 

AIAPI AIErr(* AIDocumentSuite::GetDocumentFileSpecification)(ai::FilePath &file) .

Its ended in prameter conversion error (c 2664). Can anyone guide me to get the current file path.

Thanks in advance

Sreejesh K V

This topic has been closed for replies.
Correct answer A. Patterson

ai::FilePath file;

AIErr error = sDocument->GetDocumentFileSpecification(file);

if (error != kNoError) {

  // there was a problem
}

1 reply

A. Patterson
Inspiring
November 5, 2009

That sounds like the right call -- is the file unsaved? It might not have a file specification if its unsaved.

And as a tip: the error code can be decoded, though it doesn't always result in something useful. If you view it as hex and take each pair of digits (four pairs in all) and cast them to char, you'll spell out a four character code. It often indicates something more specific for an error than 'something went wrong'. If you look at the top of some headers, you'll see #defines for error codes like 'parm' or 't!nf'.

November 6, 2009

Hi,

     Now i am having problem with initialization of the "&file" in the GetDocumentFileSpecification();

AIAPI AIErr (*GetDocumentFileSpecification) ( ai::FilePath &file );

I searched in the samples provided with the SDK and i couldn't find the example for GetDocumentFileSpecification();

Can you give me some snippets regarding the  GetDocumentFileSpecification();

A. Patterson
A. PattersonCorrect answer
Inspiring
November 6, 2009

ai::FilePath file;

AIErr error = sDocument->GetDocumentFileSpecification(file);

if (error != kNoError) {

  // there was a problem
}