最近在研究自动化测试

LoadRunner脚本练习之文件操作

上一篇 / 下一篇  2008-09-22 20:55:09

下面是LoadRunner中常用的有关文件方面的操作:

extern int errno;
Action()
{
 char new_dir[50]="D:\\newfile1";     //定义目录
 char new_file[50]="newfile1.txt";    //定义文件
 char filename[1024],command[1024];   //定义数组
 char filename[100]="D:\\newfile3\\newfile3.txt";   //定义文件目录

    char DirString[50]="D:\\newfile2";   //定义目录

    /* 创建一个目录 */
    if(mkdir(new_dir)) 
 {
  lr_output_message("Create new directory %s failed",new_dir);
  return -1;
    }
 else
 {
  lr_output_message("Create new directory %s successfully",new_dir);

 }

    /* 创建一个文件 */
    sprintf(filename,"%s\\%s",new_dir,"newfile3.txt");
 sprintf(command,"dir %s > %s /w",new_dir,filename);
 system(command);    //执行操作系统命令             

 lr_output_message("the new file name is:",filename); 

    /* 改变工作目录 */
    if(chdir(DirString)) 
 {
  lr_output_message("Unable to change the directory %s",DirString);
 }
  
 else

  lr_output_message("Change directory to %s",DirString);

    /* 删除文件 */
    if(remove(filename)==0)

  lr_output_message("Remove the file %s success",filename);
 else

  lr_output_message("Unable to remove the file %s error %d",filename,errno);

    /* 删除目录 */
    if (rmdir(new_dir)==0)

  lr_output_message("Remove the directory %s success",new_dir);
 else

  lr_output_message("Unable to remove the directory %s error %d",new_dir,errno);*/

 return 0;
}


 


TAG:

 

评分:0

我来说两句

日历

« 2024-03-26  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 14518
  • 日志数: 14
  • 文件数: 1
  • 书签数: 1
  • 建立时间: 2008-02-25
  • 更新时间: 2011-12-21

RSS订阅

Open Toolbar