#include "stdafx.h"
#include <Windows.h>
#include <stdio.h>
int _tmain(int argc, _TCHAR* argv[])
{
// if (argc!=3)
// {
// printf("Usage: cpW file1 file2\n");
// return 1;
// }
printf("dddddd");
SYSTEMTIME sys = {0};
GetLocalTime(&sys);
wchar_t newPath[] = L"C:\\Documents and Settings\\12070\\デスクトップ\\work_monitor\\";
wchar_t oldFile[] = L"C:\\temple.txt";
int len = wcslen(newPath);
wchar_t newFile[100] = {0};
wchar_t newFileName[20] = {0};
wsprintf(newFileName, L"%02d-%02d.xls", sys.wMonth, sys.wDay);
memcpy(newFile, newPath, len*2);
memcpy((char*)newFile+len*2, (char*)newFileName, wcslen(newFileName)*2);
//if (!CopyFile(argv[1],argv[2],false))
if (!CopyFile(oldFile,newFile,false))
{
printf("copy file Error:%x\n",GetLastError());
return 2;
}
return 0;
}
主要是宽字节的问题。。。
好久没有在windows下写程序了。。。
这个程序主要是解决我每周一拷贝一个自我管理的文档到我指定的目录下。。。