如何将文件保存到指定的路径? [英] How to save file to specified path ?

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

问题描述

您好,



i希望使用CStdioFile和CFileDialog的概念将文件保存到指定的路径。



i就像



CFileDialog * dlg =新的CFileDialog(FALSE,Ltxt); //打开保存文件对话框

dlg-> DoModal();

CStdioFile fle;

fle.Open(dlg-> GetFileName(),CFile :: modeCreate | CFile :: modeWrite);



但是当我更改savedialog中的路径时,它仍然只保存在我的项目文件夹中。



所以如何使用我的fle.open()中的路径?





谢谢...

Hello,

i want to save the file to the specified path using the concept of CStdioFile and CFileDialog.

i am doing like

CFileDialog *dlg = new CFileDialog(FALSE,L"txt"); // open the save file dialog
dlg->DoModal();
CStdioFile fle;
fle.Open(dlg->GetFileName(),CFile::modeCreate|CFile::modeWrite);

but when i am changing the path in the savedialog, it still save in my project folder only.

so how to use the path in my fle.open() ?


Thanks...

推荐答案

GetFileName()成员函数返回文件名而不路径。因此该文件存储在当前目录中,该目录是您的项目文件夹。要使用路径获取文件名,请使用 GetPathName()成员函数。
The GetFileName() member functions returns the file name without path. So the file is stored in the current directory which is your project folder. To get the file name with the path, use the GetPathName() member function.


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

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