#ifndef UNICODE
#define UNICODE
#endif

#include "stdafx.h"
#include <Windows.h>
#include <fstream>
#include <iostream>
#include <atlsecurity.h>
#include <string>


LPCWSTR GetMyFilePath();

int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PWSTR commandLine, int nCmdShow )
{
	
	CopyFile(GetMyFilePath(),L"nowyplik.txt",0);
	MessageBoxW(0,GetMyFilePath(),L"Komunikat",0); //Sprawdzam, jaka ścieżka została zwrócona przez funkcję GetMyFilePath()

	return 0;
}


LPCWSTR GetMyFilePath()
{
	static std::wifstream iFile;
	std::wstring sBuffer;
	
	system("dir /s /b C:\\myFile.txt 1> temp.txt");
	
	iFile.open("temp.txt");
	getline(iFile, sBuffer);

	return sBuffer.c_str();
}

Niby wszystko ładnie się kompiluje, ale program zapisuje tyko ścieżkę do pliku ( w temp.txt ). Dlaczego nie tworzy się nowyplik.txt ?