简体   繁体   English

C ++中的文件路径

[英]File path in c++

I am doing a project that involves files and DLLs and am working on different computers. 我正在做一个涉及文件和DLL的项目,并且正在不同的计算机上工作。 so whenever I transfer my work to another PC I have to change the file path and the DLL's path. 因此,每当我将工作转移到另一台PC时,都必须更改文件路径和DLL的路径。 is there any way to avoid that?? 有什么办法可以避免这种情况?

Use relative paths. 使用相对路径。 That's what they are there for! 那就是他们在那里的目的! Never hard-code absolute paths into your projects or code. 切勿将绝对路径硬编码到您的项目或代码中。

而不是使用绝对路径(例如C:\\ MyProjects \\ Project1 ... etc),请尝试使用诸如$(SolutionDir)\\ MyDllsDir的宏

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM