How to use a relative path for NET.addAssembly

4 次查看(过去 30 天)
My matlab code is in D:\CERDEC\liveFeed, but I find I have to use a full path:
function setup(this)
this.asm = NET.addAssembly('D:\CERDEC\liveFeed\bin\Debug\liveFeed.dll');
this.feed = liveFeed.Feeder('me');
end
I get an error when I try to use:
this.asm = NET.addAssembly('.\bin\Debug\liveFeed.dll');

采纳的回答

Guillaume
Guillaume 2017-10-19
Well, you have no guarantee that the current matlab working directory is 'D:\CERDEC\liveFeed\'. And honestly, it is much better to always work with full paths. But if you really want to use a relative path, you can use pwd to query the current working directory, so:
this.asm = NET.addAssembly(fullfile(pwd, '.\bin\Debug\liveFeed.dll'));
  5 个评论
Doctor G
Doctor G 2017-10-19
never-mind, I see I have to run this inside the class.m file.
Thanks for all the speedy answers.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Search Path 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by