mastiSoft
asked on
create path
Hi,
I need to create path to write binary file. I have path to MyDocuments folder and now I try to do some thing like that MyDocuments/bin.file
I need to create path to write binary file. I have path to MyDocuments folder and now I try to do some thing like that MyDocuments/bin.file
CHAR folder_path[MAX_PATH];
HRESULT result = SHGetFolderPathA(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, folder_path);
string path = folder_path.c_str() + "/myfile.bin";
this path I'll use in
ofstream outfile(path, std::ios_base::out | std::ios_base::app);
For some reason the way I create path wrong.
ASKER
Its probably an ASCII/Unicode thing. What character set are you compiling for?
The only things I included to do a quick test were
Maybe try
to see if any of those compile with your preprocessor directives
Cheers,
Chris
The only things I included to do a quick test were
#include "stdafx.h"
#include "windows.h"
#include "Shlobj.h"
#include <string>
using namespace std;
Maybe try
string path = ((string)folder_path) + string("\\myfile.bin");
// or
string path = ((string)folder_path) + L"\\myfile.bin";
// or
string path = ((string)folder_path) + _T("\\myfile.bin");
to see if any of those compile with your preprocessor directives
Cheers,
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Chris,
Now when I looked at your code I found that I forgot include <string>.
Every thing working fine now.
Now when I looked at your code I found that I forgot include <string>.
Every thing working fine now.
Open in new window
would work but be careful of the directory separator, I haven't tested the validity of the path so maybe only a single backslash "\" is required .
Cheers,
Chris