• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            voip
            風(fēng)的方向
            厚德致遠(yuǎn),博學(xué)敦行!
            posts - 52,comments - 21,trackbacks - 0
                        工作的時(shí)候?qū)懙囊粋€(gè)修改記事本的程序段。記錄下
            代碼如下:

            #include 
            <windows.h>
            #include 
            <stdio.h>
            #include 
            <string.h>
            #include 
            <direct.h>

            char Chinaname[100]="C:\\Documents and Settings\\Administrator\\桌面\\jince\\Test2\\Chinaname.txt";


            int  HoZui(char Filename[])
            {
                
            int i,j=0;
                
            int len=strlen(Filename);
                
            char s[100],s0[100]="gpj";
                
            for(i=len-1;i>=0;i--)
                
            {
                    
            if(Filename[i]=='.')
                        
            break;
                    s[j]
            =Filename[i];
                    j
            ++;
                }

                s[j]
            ='\0';
                
            if(strcmp(s,s0)==0)
                    
            return 1;
                
            else
                    
            return 0;
            }

            void mypower1(const char* StartPath,const char* FinalPath)
            {
                FILE 
            *fp1,*fp2,*fp3;
                
            int c,count=0,chage[100],flag=1;
                
            int pub[10];
                memset(pub,
            0,sizeof(pub));
                
            int i=0,j=0,k=0,n=0;

                fp1
            =fopen(StartPath,"ab+");
               
                fp2
            =fopen(FinalPath,"ab+");

                fp3
            =fopen(Chinaname,"ab+");


                
            while((c=fgetc(fp3))!=EOF)
                
            {
                    chage[i]
            =c;
                    i
            ++;
                }


                
            while(1)
                
            {
                    j
            =0;
                    
            if(count<5)
                    
            {
                        
            for(k=0;k<4;k++)
                        
            {
                            c
            =fgetc(fp1);
                            pub[j]
            =c;
                        }

                        
            if((pub[0]==177)&&(pub[1]==177)&&(pub[2]==190)&&(pub[3]==169))    
                        
            {
                            count
            ++;
                            
            for(n=0;n<4;n++)
                                fputc(chage[n],fp2);
                        }

                        
            else
                        
            {
                            
            for(n=0;n<4;n++)
                                fputc(pub[n],fp2);
                        }

                    }

                    
            else
                    
            {
                        
            if((c=getc(fp1))!=EOF)
                        
            {
                            fputc(c,fp2);
                        }

                        
            else
                            
            break;
                        
                    }

                }

            }





            void mypower2(const char* StartPath,const char* FinalPath)
            {
                FILE 
            *fp1,*fp2;
                
            int c;

                fp1
            =fopen(StartPath,"ab+");
               
                fp2
            =fopen(FinalPath,"ab+");

                
            while((c=fgetc(fp1))!=EOF)
                    fputc(c,fp2);
            }

            //FILE *fp;
            void findFile(char StartPath[],char FinalPath[])//遞歸函數(shù)
            {
                 
            char szFind[MAX_PATH];
                 WIN32_FIND_DATA FindFileData;
                 HANDLE hFind;
                 
            char szFilestart[MAX_PATH],szFilefinal[MAX_PATH];
             
                strcpy(szFind,StartPath);
                strcat(szFind,
            "\\*.*");//利用通配符找這個(gè)目錄下的所以文件,包括目錄
             
                 hFind
            =FindFirstFile(szFind,&FindFileData);
                    
            if(INVALID_HANDLE_VALUE == hFind)    return;
                
                    
            while(TRUE)
                    
            {
              
                        
            if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)//這是目錄
                        {
                               
            if(FindFileData.cFileName[0]!='.')//.表示當(dāng)前目錄,因?yàn)槊總€(gè)目錄下面都有兩個(gè)默認(rèn)目錄就是..和.分別表示上一級(jí)目錄和當(dāng)前目錄
                               {
                                
            //system ("PAUSE");
                            /*    if(strcmp(FindFileData.cFileName,"image")!=0)
                                { 
                                    printf("當(dāng)前路勁為:\n%s\n   請(qǐng)修改Chinaname文件夾\n",StartPath);
                                    system ("PAUSE");
                                }
            */

                                strcpy(szFilestart,StartPath);
                                strcat(szFilestart,
            "\\");
                                strcat(szFilestart,FindFileData.cFileName);



                                strcpy(szFilefinal,FinalPath);
                                strcat(szFilefinal,
            "\\");
                                strcat(szFilefinal,FindFileData.cFileName);
                                mkdir(szFilefinal);


                                findFile(szFilestart,szFilefinal);
            //尋找這個(gè)目錄下面的文件
                               }

                        }

                        
            else
                        
            {
                                 
            //  fprintf(stdout,"%s\\%s\n",StarPath,FindFileData.cFileName);//打印出目錄下的文件的路徑和名稱
                                   char Filename[100];
                                   strcpy(Filename,FindFileData.cFileName);

                                   strcpy(szFilestart,StartPath);
                                   strcat(szFilestart,
            "\\");
                                   strcat(szFilestart,FindFileData.cFileName);

                                   strcpy(szFilefinal,FinalPath);
                                   strcat(szFilefinal,
            "\\");
                                   strcat(szFilefinal,FindFileData.cFileName);
                                 
            //  fprintf(fp,"%s\\%s\n",StarPath,FindFileData.cFileName);//這將結(jié)果存檔到c:\\path.txt中。
                                    if(HoZui(Filename))
                                    
            {
                                        mypower2(szFilestart,szFilefinal);
                                    }

                                    
            else
                                    
            {
                                        mypower1(szFilestart,szFilefinal);
                                    }


                        }

                        
            if(!FindNextFile(hFind,&FindFileData))//尋找下一個(gè)文件
                                  break;
                    }

                    FindClose(hFind);
            //關(guān)閉句柄
            }


            int main()
            {
            // fp = fopen("C:\\path.txt","w");
             char FinalPath[100]="C:\\Documents and Settings\\Administrator\\桌面\\jince\\Test3";
             
            char StartPath[100]="C:\\Documents and Settings\\Administrator\\桌面\\jince\\Test2";
             findFile(StartPath,FinalPath);
            //遍歷StartPath下的所有文件,把它寫到FinalPath下
             
            //fclose(fp);
             return 0;
            }

            文件夾遍歷相關(guān)鏈接:http://94here.blog.51cto.com/696155/160870/        
            WIN32_FIND_DATA屬性說明: http://www.cnblogs.com/ty--90/archive/2008/02/21/1076072.html
            posted on 2010-09-15 09:17 jince 閱讀(307) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 學(xué)習(xí)到的一些小知識(shí)

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            相關(guān)文章:
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            哈哈哈哈哈哈
            国产∨亚洲V天堂无码久久久| 久久久国产精品网站| 久久久精品国产Sm最大网站| 精品久久久久久99人妻| 中文成人无码精品久久久不卡 | 国产精品99久久精品| 91精品国产高清久久久久久91 | 久久久久久国产精品美女| 午夜精品久久久久久影视777| 亚洲愉拍99热成人精品热久久| 久久一日本道色综合久久| 久久激情亚洲精品无码?V| 亚洲乱码精品久久久久..| 国产精品无码久久四虎| 久久久久久久久久久久中文字幕 | 无码任你躁久久久久久| 久久99国产精品尤物| 波多野结衣久久一区二区| 一本大道久久a久久精品综合| 久久天天躁夜夜躁狠狠躁2022 | 久久香蕉超碰97国产精品| 久久精品成人一区二区三区| 久久天天躁狠狠躁夜夜96流白浆| 很黄很污的网站久久mimi色| 久久精品国产亚洲av日韩| 亚洲日韩中文无码久久| 精品国产日韩久久亚洲| 久久精品中文字幕有码| 99久久精品国产综合一区| 99精品久久精品| 久久精品欧美日韩精品| 一本一本久久A久久综合精品| 青春久久| 亚洲日韩欧美一区久久久久我| 伊人久久大香线焦综合四虎 | 国产精品99久久久久久猫咪| 狠狠久久亚洲欧美专区| 国产麻豆精品久久一二三| 国产人久久人人人人爽| 久久免费小视频| 久久av免费天堂小草播放|