简体   繁体   English

如何在运行时使用C ++选择和打开文件?

[英]How to choose and open a file during runtime with C++?

At the moment I am creating an Editor for Textures and I want to choose the textures during runtime. 目前,我正在创建纹理编辑器,我想在运行时选择纹理。 Later I would like to choose the save directory for new textures. 稍后,我想选择新纹理的保存目录。

I found the How to: Open Files Using the OpenFileDialog Component . 我找到了如何:使用OpenFileDialog组件打开文件 But I think this is not the solution. 但是我认为这不是解决方案。 打开文件对话框

(assuming you are on Windows, pas per screenshot) If you simply want to select a folder, you can use SHBrowseForFolder. (假设您使用的是Windows,每屏截取一次)如果只想选择一个文件夹,则可以使用SHBrowseForFolder。

http://msdn.microsoft.com/en-us/library/windows/desktop/bb762115%28v=vs.85%29.aspx http://msdn.microsoft.com/zh-cn/library/windows/desktop/bb762115%28v=vs.85%29.aspx

M. M.

You need to look at the Common Dialog Library. 您需要查看“通用对话框库”。

http://msdn.microsoft.com/en-gb/library/windows/desktop/ms645524(v=vs.85).aspx http://msdn.microsoft.com/zh-CN/library/windows/desktop/ms645524(v=vs.85).aspx

Or, if you are only interested in Vista/Windows 7 support, you could consider the Common Item Dialogs instead. 或者,如果您仅对Vista / Windows 7支持感兴趣,则可以考虑使用“公共项”对话框。

http://msdn.microsoft.com/en-gb/library/windows/desktop/bb776913(v=vs.85).aspx http://msdn.microsoft.com/zh-CN/library/windows/desktop/bb776913(v=vs.85).aspx

For 'native' C++ you wouldn't be able to easily use the .NET components that your link refers to. 对于“本机” C ++,您将无法轻松使用链接所引用的.NET组件。

I have solved my problem with using the dirent.h file. 我已经使用dirent.h文件解决了我的问题。 I have acknowledge of this file by founding this post How can I get the list of files in a directory using C or C++? 我已经通过创建此帖子确认了此文件, 如何使用C或C ++获取目录中的文件列表?

I have write my own fileexplorer by using dirent.h and SFML. 我已经使用dirent.h和SFML编写了自己的fileexplorer。

Sorry if i can't illustrate my problem. 对不起,如果我不能说明我的问题。

but thanks for the replies (: 但感谢您的答复(:

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

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