E
E
egorzenit2019-03-15 20:01:28
C++ / C#
egorzenit, 2019-03-15 20:01:28

How to add // to path instead of / in C++?

There are two questions about paths in C++
. I use two functions.
First: With the help of it I get the path to the file where it lies and the program gives me the address "C:\Folder\file.exe" With the help of the second function, I get the file from the server and I want to place it at the location address that the first function receives.
GetModuleFileNameA(NULL, szPath, MAX_PATH);

bool tool::downloadFile(string url, string filepath) {

  DeleteUrlCacheEntry(url.c_str());

  HRESULT hr = URLDownloadToFile(
    NULL,  
    url.c_str(),
    filepath.c_str(),
    0,     
    NULL); 

  if (SUCCEEDED(hr))
    return true;
  else
    return false;

}

The problem is that you need to somehow convert from the usual path:
"C:\Folder\file.exe"
to a path with double slashes so that the program can put this file in the folder I need.
"C:\\Folder\\file.exe" Tell me
how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-03-15
@egorzenit

Escaping slashes only makes sense in literals. If you're getting a string into a variable from a function, you don't need to worry about escaping.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question