Ram
Ram

Reputation: 3133

C++ method to check if a File is on Disk wchar_t

I wanted a means of checking is a file exists on the disk based on wchar_t * path. A ready to use method is available on SO but for char * path. Is there a variant for wchar_t * without using boost.

Upvotes: 1

Views: 896

Answers (1)

ivaigult
ivaigult

Reputation: 6667

Loot at this example:

#include <fstream>
#include <string>

bool check_if_file_exists(std::wstring path)
{
    std::ifstream ff(path.c_str());
    return ff.is_open();
}

But this is windows only, since std::ifstream(wchar_t*) is MSVC extension.

Upvotes: 1

Related Questions