c++ - CopyFile doesn't work with environmental strings but works only with standard directories where files are placed. Anyway to get past this? -


I want to copy a file directly from WinAPI using the CopyFile () function.

The code works, but the file is not copied.

Here is the code -

  copyfile ("%% temp %% \\ test.txt" "," D: \\ Tutorial \\ test.txt ", Incorrect);   

If I type something like %% temp %% \\ test.txt to D: \ test \ test.txt

How do any ideas get past this?

The path to the Win32 file API requires the actual path, not the string expression that evaluates the paths They do not extend the variable.

If you want to expand the variable on a path, then pass it through ExpandEnvironmentStrings (and one % before and CopyFile .

Of course, if you are trying hard disk access to a temporary directory ,>% TEMP% \ test.txt in a configuration file, then you should instead call GetTempPath for a temporary directory OS Policy should be used. (Later, use PathCchCombine to merge the directory name and file name)

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -