已知SYSTEMTIME类型时间,怎么变换让其成为文件名啊
已知SYSTEMTIME类型时间,如何变换让其成为文件名啊?
通过高手们的帮助,我可以获得时间了
不过是SYSTEMTIME类型的
那如何进行转换才能以此为文件命名呢?
我知道用RENAME函数来命名.参数的设置(第2个)如何设置呢?
谢谢帮忙...
------解决方案--------------------
COleDateTime dtCurrent;
dtCurrent = COleDateTime::GetCurrentTime();
CString strData = dtCurrent.Format( "%Y-%m-%d %H-%M-%S ");
这个时间就是 CString 类型了
------解决方案--------------------
CFile::Rename(char *old,char *new)
char *oldName = file.GetBuffer(file.GetLength()) ;
char *newName = strTemp.GetBuffer(file.GetLength());
------解决方案--------------------
没用mfc的话
用_snprintf
或者用stringstream拼接转换
------解决方案--------------------
SYSTEMTIME t;
stringstream s;
s < <t.dwyeah < <t.wMonth ..... < < t.wMilliseconds ;
string str;
s> > str;
这个str就可以当成文件名字了
------解决方案--------------------
假如你的时间为SYSTEMTIME型变量time
char filename[256];
sprintf(filename, "%d年%d月%d日%d时%d分%d秒 ",time.wYear,time.wMonth,time.wDay
,time.wHour,time.wMinute,time.wSecond);
------解决方案--------------------
SYSTEMTIME st;
GetLocalTime(&st);
CString fileName;
fileName.Format( "%d-%d-%d ",st.Year,st.Month,st.Day);
得到的文件名是:yyyy-mm-dd;
剩下的不用我说了吧
通过高手们的帮助,我可以获得时间了
不过是SYSTEMTIME类型的
那如何进行转换才能以此为文件命名呢?
我知道用RENAME函数来命名.参数的设置(第2个)如何设置呢?
谢谢帮忙...
------解决方案--------------------
COleDateTime dtCurrent;
dtCurrent = COleDateTime::GetCurrentTime();
CString strData = dtCurrent.Format( "%Y-%m-%d %H-%M-%S ");
这个时间就是 CString 类型了
------解决方案--------------------
CFile::Rename(char *old,char *new)
char *oldName = file.GetBuffer(file.GetLength()) ;
char *newName = strTemp.GetBuffer(file.GetLength());
------解决方案--------------------
没用mfc的话
用_snprintf
或者用stringstream拼接转换
------解决方案--------------------
SYSTEMTIME t;
stringstream s;
s < <t.dwyeah < <t.wMonth ..... < < t.wMilliseconds ;
string str;
s> > str;
这个str就可以当成文件名字了
------解决方案--------------------
假如你的时间为SYSTEMTIME型变量time
char filename[256];
sprintf(filename, "%d年%d月%d日%d时%d分%d秒 ",time.wYear,time.wMonth,time.wDay
,time.wHour,time.wMinute,time.wSecond);
------解决方案--------------------
SYSTEMTIME st;
GetLocalTime(&st);
CString fileName;
fileName.Format( "%d-%d-%d ",st.Year,st.Month,st.Day);
得到的文件名是:yyyy-mm-dd;
剩下的不用我说了吧