• <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
            風的方向
            厚德致遠,博學敦行!
            posts - 52,comments - 21,trackbacks - 0
                        工作的時候寫的一個修改記事本的程序段。記錄下
            代碼如下:

            #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[])//遞歸函數
            {
                 
            char szFind[MAX_PATH];
                 WIN32_FIND_DATA FindFileData;
                 HANDLE hFind;
                 
            char szFilestart[MAX_PATH],szFilefinal[MAX_PATH];
             
                strcpy(szFind,StartPath);
                strcat(szFind,
            "\\*.*");//利用通配符找這個目錄下的所以文件,包括目錄
             
                 hFind
            =FindFirstFile(szFind,&FindFileData);
                    
            if(INVALID_HANDLE_VALUE == hFind)    return;
                
                    
            while(TRUE)
                    
            {
              
                        
            if(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)//這是目錄
                        {
                               
            if(FindFileData.cFileName[0]!='.')//.表示當前目錄,因為每個目錄下面都有兩個默認目錄就是..和.分別表示上一級目錄和當前目錄
                               {
                                
            //system ("PAUSE");
                            /*    if(strcmp(FindFileData.cFileName,"image")!=0)
                                { 
                                    printf("當前路勁為:\n%s\n   請修改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);
            //尋找這個目錄下面的文件
                               }

                        }

                        
            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);//這將結果存檔到c:\\path.txt中。
                                    if(HoZui(Filename))
                                    
            {
                                        mypower2(szFilestart,szFilefinal);
                                    }

                                    
            else
                                    
            {
                                        mypower1(szFilestart,szFilefinal);
                                    }


                        }

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

                    FindClose(hFind);
            //關閉句柄
            }


            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;
            }

            文件夾遍歷相關鏈接: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 閱讀(301) 評論(0)  編輯 收藏 引用 所屬分類: 學習到的一些小知識
            哈哈哈哈哈哈
            精品欧美一区二区三区久久久| 深夜久久AAAAA级毛片免费看| 很黄很污的网站久久mimi色| www性久久久com| 色综合久久久久综合体桃花网 | 久久66热人妻偷产精品9| 久久受www免费人成_看片中文| 国内精品久久久久国产盗摄| 日本三级久久网| 久久国产香蕉一区精品| 精品国产91久久久久久久a| 99精品久久久久久久婷婷| 精品久久久久久99人妻| 久久精品这里只有精99品| 久久久无码精品亚洲日韩软件| 久久99热这里只有精品国产| 久久综合九色综合欧美就去吻| 亚洲精品无码久久毛片| 久久久久se色偷偷亚洲精品av | 综合久久国产九一剧情麻豆| 国产成人无码精品久久久性色| 人妻丰满AV无码久久不卡| 91精品国产高清久久久久久io| 久久这里只精品国产99热| 欧美伊人久久大香线蕉综合69| 2021国产精品久久精品| 久久亚洲私人国产精品vA| 7777久久久国产精品消防器材| 亚洲综合日韩久久成人AV| 国产精品久久成人影院| 无码精品久久一区二区三区| 亚洲∧v久久久无码精品| 91精品久久久久久无码| 亚洲一级Av无码毛片久久精品| 久久国产精品99国产精| 久久久久久无码国产精品中文字幕| 久久久久久伊人高潮影院| 国产精品久久久天天影视香蕉| 欧美精品国产综合久久| 国产日韩欧美久久| 久久水蜜桃亚洲av无码精品麻豆|