File copy

Posts 1–6 of 6 · Page 1 of 1
File copy
I'm creating an application for sorting text documents based on their contents.
The ap works like this: I have a folder where the files I want sorted are, I supply parameters for my filter, and then a path where I want the appropriate file copied to (say I want to sort for the letter 'a', my ap seeks the right file, and then copies it to the given result dir)

But I've come accros problems, The position of the files to sort is hard-coded, but the result location isn't, it's a string that the user supplies.

Say that I want to list the results here:

"C:\TESTMAP\Testing map folder\sometxt.txt"

The problem is, every time I give my program a string:

C:\TESTMAP\Testing map folder\sometxt.txt

The program doesn't copy anything, after some error checking I see that windows shoves an error 123 (ERROR_INVALID_NAME, aka: The filename, directory name, or volume label syntax is incorrect)

What's going wrong?
Put 2 backslashes:

C:\\TESTMAP\\Testing map folder\\sometxt.txt

If there are any spaces in the path, like the one you posted, you have to add quotes, meaning quotes in a quote. To put a quote in a quote just use add a backslash before the quote character.

[php]
char* szPath = "\"C:\\TESTMAP\\Testing map folder\\sometxt.txt\"";
[/php]
In addition to Void's statement, go read up on escape characters in C++ (or C#).
No those weren't the problems, but I fixed them already on my own
(I was unable to reach mpgh the last couple of days, so that's for my late response)
Quote Originally Posted by .::SCHiM::. View Post
No those weren't the problems, but I fixed them already on my own
(I was unable to reach mpgh the last couple of days, so that's for my late response)
Share solution please. |:
Quote Originally Posted by Void View Post
Share solution please. |:
Well it was verry stupid actually , in my days of C++ noobyness I tended to use cin >> to get every imput I needed, but cin >> only receives imput until the next delimiter symbol is found (in this case a space) so when imputing a path with a space in it, my program would fail

So now I use getline(cin, buffer);
Posts 1–6 of 6 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us