导出当前文件夹下的png图片路径名

#include <windows.h>
#include<iostream>
#include<io.h>
#include <fstream>
#include <string> 
#include <direct.h>  
using namespace std;
int main()
{
_finddata_t file;
long lf;
ofstream ofs;  //提供写文件的功能
ofs.open("d:\\outFile.txt",ios::trunc); //trunc打开文件时,清空已存在的文件流,若不存在此文件则先创建
//char nameStart[] = "{type:'image', src:\"";
//char namEnd[] = "\"},";
char nameStart[] = "\"res/";
char namEnd[] = "\",";
cout<<"*****************************************************"<<"\n\n";
cout<<"生成txt文件路径:"<<"d:\\\\outFile.txt"<<"\n\n";
cout<<"*****************************************************"<<"\n\n";
cout<<"输入检索路径格式如下:"<<"\n";
cout<<"F:\\\\MyFile\\\\Published-HTML5\\\\mainframe\\\\*.png"<<"\n\n";
cout<<"*****************************************************"<<"\n";
cout<<"input path :"<<endl;
char a[2000];
char d[] = "\\*.png";
//cin.get(a,2000);
GetCurrentDirectory(MAX_PATH,a);
strcat(a,d);
//cin>>"文件路径:";
//输入文件夹路径
cout<<"输入生成文本的格式:\n";
char b[500];
cin.get(b,500);
char resStart[] = "\"";
char resEnd[] = "\"";
if((lf = _findfirst(a, &file))==-1)
 cout<<"Not Found!"<<endl;
else{
 //输出文件名
 cout<<"file name list:"<<endl;
 while(_findnext( lf, &file)==0){
  cout<<file.name<<endl;
  //ofs<<nameStart<<file.name<<namEnd<<"\n";
  ofs<<resStart<<b<<file.name<<resStart<<"\n";
 }
}
_findclose(lf);
//return 0;
}
char* mystrcat(char* destStr,const char* srcStr)  //如果两个字符串是同一个字符串呢?
{
char* temp=destStr;
while(*destStr != '\0')
{
 ++destStr;
}
while(*destStr++ = *srcStr++)
 NULL;
return temp; //为了实现链式操作,将目的地址返回
}

猜你喜欢

转载自blog.csdn.net/tang_bo_hu_2011/article/details/50468072