如何传递文件路径 [英] how to pass the file path

查看:85
本文介绍了如何传递文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何将路径传递给ifstream来读取文件。



c:\\ \\\ folder1 \\ temp.txt



folder1的名称不固定。



谢谢。

Hi,

How to pass the path to ifstream to read file.

c:\\folder1\\temp.txt

name of folder1 is not fixed.

Thank you.

推荐答案

如果你想创建一个路径,那么你可以查看 fnsplit fnmerge 如果编译器上有可用的函数。



这将允许您根据需要拆分或合并路径部分。如果这些功能不可用,那么你可能有一些选择,或者你可以创建自己的功能。



顺便说一句,从哪里来的文件夹的名称和文件的名称?



通常,组合路径路径的函数会在必要时添加必要的路径分隔符。这很有用,因为目录名可能有最终的\取决于你得到它。
If you want to create a path, then you might look at fnsplit and fnmerge functions if there are available on your compiler.

This will allows you to split or merge paths parts as desired. If those function are not availables, then you might have some alternatives or you can create your own functions.

By the way, from where come the name of the folder and the name of the file?

Usually a function that combine path path will add necessary path separator if necessary. This is useful as directory name might have the final \ or not depending on how you get it.


这应该对你有帮助。



http://stackoverflow.com/questions/843083/open -file-by-its-full-path-in-c [ ^ ]
This should help you.

http://stackoverflow.com/questions/843083/open-file-by-its-full-path-in-c[^]


这篇关于如何传递文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆