验证_tmkdir是否成功

发布于 2024-08-09 07:45:44 字数 294 浏览 2 评论 0原文

任何人都可以帮我找出如何验证 _tmkdir 是否成功。 例如,我希望在另一个文件夹中创建一个文件。我将在运行时创建该文件夹。所以我将给出以下命令。

sFilePath = sFilePath + _T("\\P-Series Communication Logs");
_tmkdir( sFilePath );

其中 sFilePath 最初包含从注册表获取的软件安装路径。

我想知道 _tmkdir 是否成功。

谢谢

Can anybody help me in finding out how to verify that _tmkdir succeeded.
For example i wish to create a file within another folder. This folder i will create at runtime. So i will give the following command.

sFilePath = sFilePath + _T("\\P-Series Communication Logs");
_tmkdir( sFilePath );

where sFilePath would initially contain a software installation path which will be obtained from registry.

i wish to know if _tmkdir succeeded or not.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

煮酒 2024-08-16 07:45:44

您可以通过查看_tmkdir的返回值来判断调用是否成功。如果失败,errno 全局变量会指示失败的原因:

int result = _tmkdir(sFilePath);
if (result == 0) {
    // succeeded
}
else {
    // failed
    if (errno == EEXIST) {
        // already exists!
    }
}

有关详细信息,请参阅 _tmkdir 的 MSDN 文档 此处errno 此处

我希望这有帮助!

You can check the return value of _tmkdir to see if the call succeeded. If it failed, the errno global variable indicates the reason for failure:

int result = _tmkdir(sFilePath);
if (result == 0) {
    // succeeded
}
else {
    // failed
    if (errno == EEXIST) {
        // already exists!
    }
}

For more information, look at the MSDN documentation for _tmkdir here and errno here.

I hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文