No ever seen problem, even on the internet.

Hi everybody, I'm Brazilian and mechanical engineer student. So, sorry for any bad English grammar.

Here's the thing, i tried to do a program but i couldn't do it nor find a way to do by the internet =/

I'm trying to do a program to organize the patients profiles of my father by year, month and day, putting them in their correspondent folders. The archive name structure is "year'month'day Name of Patient" and its type is ".txt" from Notepad. Ex: "2010'08'15 Robert.txt" and goes to the folder ".../2010/August/15."

I thought to make it more simple, just analyzing the date and run through it since now to like 30 years ago. In another words, bool moving them from 2010~2040, 01~12, 01~31 (depending of the month) even if the file is not there.

For moving the files, i found this code:

"MoveFile(old_folder, new_folder)", so i worked on it. But i got a problem on the string responsible for the path of the file.

// Ok here it goes:

#include <cstdlib>
#include <iostream>
#include <windows.h>

using namespace std;

int main(int argc, char *argv[]){
// actual site
CHAR actual_site[] = "C:\\test\\folder1\\test.txt";
// new site
CHAR new_site[] = "C:\\test\\folder2\\test.txt";
// moving the archive
if(MoveFile(actual_site, new_site)){
cout << "Archive moved." << endl;
}
else{
cout << "Error with archive: " <<
GetLastError() << endl;
}

system("PAUSE");
return EXIT_SUCCESS;
}

//
what i wanted to do, is... for the actual_site, scan all the names (or one-by-one) on the folder and work with them in variables. Then, analyse it and choose a destination. But for make it simple, since i havent found how to work with the names, it can be just to bool all possible actual_site's.

the problem.. can't do that:

string test = test.txt
// actual site
CHAR actual_site[] = "C:\\test\\folder1\\"+test;
// new site
CHAR new_site[] = "C:\\test\\folder2\\"+test;

*initializer fails to determine size of `local_atual';
*initializer fails to determine size of `novo_local';
*cannot convert `std::string*' to `const CHAR*' for argument `1' to `BOOL MoveFileA(const CHAR*, const CHAR*)'.

I need to do that to be possible booling and deciding what folder to move.

Can anyone help, please? =)
Oh... I thought this was going to be something about traversing a directory tree... How dull.

1
2
3
4
5
typedef std::basic_string<CHAR> WinStdString;

WinStdString test=TEXT("test.txt"),
    current_site=TEXT("c:/test/folder1/")+test,
    new_site=TEXT("c:/test/folder2/")+test;


By the way,
In another words, bool moving them
it can be just to bool all possible actual_site's.
I need to do that to be possible booling
You keep using that word, and I don't think it means what you think it means.
Topic archived. No new replies allowed.