CVI⽂件的相关操作1.新建⼀个空⽩的⽂件
char filePath[256];
int fileHandle;
if (FileExists( FILE_PATH,0)< 1)//检测⽂件夹是否存在,FILE_PATH为⽂件夹路径
{
CreateDirectory(FILE_PATH, NULL);//创建⽂件夹
}
sprintf (filePath, "%s\\%s.txt", FILE_PATH, fileName);
if (1 == FileExists (filePath, NULL))//如果⽂件存在
{
DeleteFile (filePath);//删除⽂件
}
fileHandle = OpenFile (filePath, VAL_READ_WRITE, VAL_OPEN_AS_IS, VAL_ASCII);//新建⽂件夹 CloseFile (fileHandle);//关闭⽂件
2.重命名
char existingFilePath[64], newFilePath[64];
ascii文件夹怎么创建sprintf (existingFilePath, "%s\\%s.txt", TPF_FILE_PATH, existingFileName);
sprintf (newFilePath, "%s\\%s.txt", TPF_FILE_PATH, newFileName);
RenameFile (existingFilePath, newFilePath);
3.删除⽂件
char filePath[64];
sprintf (filePath, "%s\\%s.txt", TPF_FILE_PATH, name);
DeleteFile (filePath);
4.另存为⽂件
char sourceFilePath[64], targetFilePath[64];
sprintf (sourceFilePath, "%s\\%s.txt", TPF_FILE_PATH, sourceFileName);
sprintf (targetFilePath, "%s\\%s.txt", TPF_FILE_PATH, targetFileName);
CopyFile (sourceFilePath, targetFilePath);
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论