D
D
Dutymy2021-10-22 21:39:54
C++ / C#
Dutymy, 2021-10-22 21:39:54

How to allow Russian letters on the file path?

I write a function to check the existence of a file:

#include <Windows.h>
#include <stdio.h>  
#include <sys/stat.h> // fastest way to get file existens
#define MAX_NAME 255
using namespace std;


int main()
{
findPath:
  printf("Enter path \n");
  wchar_t targetPath[MAX_NAME];
  fgetws(targetPath, MAX_NAME, stdin);
  
  struct _stat buffer;
  if (_wstat(targetPath, &buffer) == 0) { // fastest way to get file existens  //!breakpoint here
    wprintf(L"file %s opened succesfull \n", targetPath);
  }
  else {
    wprintf(L"No file like %s found, try again \n", targetPath);
    goto findPath;
  }
}

But everything breaks if the path is for example C:\Users\Admin\Desktop\folder chick\test.txt
Although wpintf output is correct in visualStudio debug targetPath ==L"C:\Users\Admin\Desktop\folder @$%\test.txt\n"

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question