开发者

Adding two path names in VC++

String^ Source = System::IO::Directory::GetCurrentDirectory()+ "\\DeleteFolder.exe\"" ;
String^ Destination = "C:\\Windows\\DeleteFolder.exe";
pin_ptr<const wchar_t> WSource = PtrToStringChars(Source);
pin_ptr<const wchar_t> WDestination = PtrToStringChars(Destination);
开发者_如何转开发

Is there any problem with the code above, i am unable to get the source path


Note, I've never done managed C++ so the below is just an educated guess.

You end the source path with \". I assume to get the path to be surrounded by " to handle spaces etc, but as far as I can tell you're not adding one to the beginning of the path.

Also, rather than adding paths together, there's a method to do just that so you don't have to worry about slashes etc, just do:

String^ Source = System::IO::Path::Combine(System::IO::Directory::GetCurrentDirectory(), "DeleteFolder.exe")

And then just surround the source path with the " if they are needed as:

Source = "\"" + Source + "\""
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜