Error converting std :: tr2 :: sys :: path to std :: string?

I am using the Visual Studio 2013 TR2 File System Library. I see an error while converting the UNC path to string:

#include "StdAfx.h"
#include <filesystem>
#include <iostream>

//------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
    namespace fs = std::tr2::sys;

    fs::path fsPath = "//server/dir";

    std::string sPath = fsPath;

    std::cout << sPath.c_str() << "\n";
}

      

This will print "\ server \ dir", not "\\ server \ dir".

Is there a fix or workaround for this? Am I doing something wrong?

+3


source to share


1 answer


Well I found a workaround that works for me. If i use

sPath = fsPath.string();

      



Now I can pass this string to the std :: ifstream constructor. The path string will be "// server / dir", not "\\ server \ dir".

0


source







All Articles