• <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   管理


            哈哈哈哈哈哈
            久久久精品无码专区不卡| 久久精品蜜芽亚洲国产AV| 久久精品成人免费观看97| 伊人久久免费视频| 国产精品久久久久久五月尺| 乱亲女H秽乱长久久久| 国产成人久久精品麻豆一区| 一本综合久久国产二区| 久久精品成人免费看| 久久久久久久波多野结衣高潮| 久久丫精品国产亚洲av| 天天综合久久一二三区| 国产成人久久精品区一区二区| 日本久久中文字幕| 日本免费久久久久久久网站| 18岁日韩内射颜射午夜久久成人 | 久久99精品久久久久久不卡| 久久久久久久91精品免费观看| 99精品久久精品一区二区| 国内精品伊人久久久久妇| 国产精品九九久久免费视频| 久久国产色AV免费看| 少妇人妻综合久久中文字幕| 久久精品成人免费国产片小草| 国产精品久久久久久福利漫画| 777午夜精品久久av蜜臀 | 久久婷婷五月综合国产尤物app| 狠狠色伊人久久精品综合网| 久久精品成人免费看| 无码人妻少妇久久中文字幕蜜桃| 久久精品国产亚洲av瑜伽| 精品少妇人妻av无码久久| 色妞色综合久久夜夜| 精品久久久无码21p发布| 中文字幕无码久久精品青草| 久久久久免费视频| 性做久久久久久久久老女人| 色综合久久中文字幕综合网| 欧美国产成人久久精品| 综合久久一区二区三区 | 久久久精品一区二区三区|