Book a Demo

Author Topic: Cannot open EAP file from a mapped network drive, using C# automation API  (Read 6608 times)

mateiacd

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Hello,

I am using Enterprise Architect 12.1.0.1229

I would like to use the Automation API in C# to open an EAP from a mapped network drive, like U:, R: etc

I mention that I have read/write access in these network folders and I also mention that the code works perfectly with models
opened from the local drive C: or from a MySQL database repository.

Using the simple code indicated below:
http://www.sparxsystems.com/enterprise_architect_user_guide/12.1/automation_and_scripting/setup.html

  EA.Repository r = new EA.Repository();
  r.OpenFile("U:\\getting-started.eap");
  r.CloseFile();
  r.Exit()

I always get the System.Runtime.InteropServices.COMException  error message:

Quote
An error has occurred: "U:\\getting-started.eap"  isn't a valid path.
Make sure that the path name is spelled correctly and you are connected to the server
on which the file resides.

The Interop.EA.dll version is 2.10.238.1, size 303104 bytes, dated 16.03.2016
« Last Edit: October 07, 2016, 11:44:56 pm by mateiacd »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
I see that the error message you quoted mentions "U:\\..."
Does that mean that the "\\" didn't get translated to a single backslash?

Because in fact "U:\\something" is indeed not a valid path, it should be "U:\something" with a single backslash

Geert

mateiacd

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Hi Geert

Now I understand what you wanted to say....

I mistyped the error message when I posted my question.
The error message looks like this:
Quote
An error has occurred: "U:\getting-started.eap"  isn't a valid path.

Thank you for answering, yes  indeed, "\\" gets translated to a single backslash.


The syntax  is correct. In C# folder paths must contain \\ as a folder separator.

And as mentioned, if I open a local model, like r.OpenFile("C:\\getting-started.eap");  everything is fine

And for the sake of clarity this doesn't work as well r.OpenFile(@"U:\getting-started.eap");

It's not a matter of syntax, for some reason, the Automation API doesn't work for mapped network drives.

The EA product itself (GUI) works fine.
« Last Edit: October 07, 2016, 11:37:52 pm by mateiacd »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
So for some reason the mapped drive is not transparent to the EA API?
In that case I guess you have no choice but to use the full address of the network drive.

Geert