K
K
Kirill H2016-08-12 12:36:48
C++ / C#
Kirill H, 2016-08-12 12:36:48

How to copy a file to a new C++ folder?

1. The program creates a folder with the name specified by the user
2. We have a Data resource folder in the folder with the program executable
3. You need to copy the file from the Data folder to the newly created user
The problem is clear to me and seems to have already found a solution, but it gives error while copying, does not accept the name string data type in the copyfile command. (Save is SaveDialog1, just stung the name so as not to write a long one).

String name = Edit1->Text;
Save->FileName = name;
name+="\\title.ly";
if (Save->Execute()) {
  CreateDir(Save->FileName);
  CopyFile("data\\title.ly", name, true);
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
iv_k, 2016-08-12
@KirillHelm

and f-I CopyFile what type does it require from you?
maybe she needs wchar_t?
something like
(const wchar_t*)name.utf16()

V
Vladimir Martyanov, 2016-08-12
@vilgeforce

Casting String to char* will save you. Perhaps something like name.c_str() is needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question