FSTREAM不创建具有附加到文件名的ASCTIME值的文件
fstream not creating a file with a asctime value appened to the file name
我已经对此进行了调试,直到我知道这个问题,我只是不知道如何解决。
现在我正在使用:
file.open(logFile.c_str(), std::ios::out | std::ios::app);
只要我评论以下标记的行:
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime (&rawtime);
logFile = "bin/";
if(_DEBUG) { logFile += "Debug/"; }
else { logFile += "Release/"; }
logFile += fileName;
if(_DEBUG) { logFile += "Debug-"; }
else { logFile += "Release-"; }
logFile += asctime(timeinfo); // Works fine with this line commented.
logFile += ".log";
那么,我该如何使此行正确使用?
至少对于ntfs而言,结肠(:
)是文件名的非法字符。尝试使用strftime()
而不是格式化一个不包含结肠的字符串。
我会猜测。例如,将时间添加到您的文件名中,例如12:23:34。我猜您正在使用文件名中使用结肠不合法的文件系统。
解决方案(如果我的猜测是正确的话),请用下划线或类似。
相关文章:
- 从命令行c++发送文本文件名
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 为什么文件名被设置为一个点,而不是在读取矢量中的文件名时
- 当Microsoft文档仅包含 C# 示例时,如何查找 C++ 包含文件名
- 如何在CPP的给定目录中列出UTF编码的文件名?
- 在Visual Studio 2019中保存时ReadDirectoryChangesW文件名的问题
- C++:在Windows中浏览名称中带有点的文件名
- 我在 ifstream input_file(文件名)行中收到错误"no matching function to call";
- 不带预处理器的调用方法/文件的文件名/行号
- 在 C++ 中为文件名添加时间戳
- 为什么当我在 std::string 中打开文件名的 fstream 时出现"no matching function"错误?
- 如何将文件名作为参数传入并正确打开?
- 如何在目录及其子文件夹中构建文件名字符串向量?
- 要求用户输入C++输出文件名
- 是否有一种标准方法来计算两个 asctime() 值之间的天数
- 从Arduino SD卡模块到Array的文件名
- 如何使用打印到 PDF 打印机在 MFC 和 CView 中以编程方式打印而不提示输入文件名?
- C++ 从变量导入文件名
- 从 Makefile 中的 $@ 获取文件名
- FSTREAM不创建具有附加到文件名的ASCTIME值的文件