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

            JS讀寫ini文件






            //////////////////////////////////////////////////////////////////////////////////////
            function print(){
            fso = new ActiveXObject("Scripting.FileSystemObject");
            tf = fso.CreateTextFile("E:\\test.ini", true); 
            tf.WriteLine("要寫入的內容");
            tf.Close();
            }
            /////////////////////////////////////////////////////////////////////////////////////

            using System;
            using System.Runtime.InteropServices;
            using System.Text;
            using System.IO;

            namespace Common
            {
                /// <summary>
                /// INI文件讀寫類。
                /// </summary>
             public class INIFile
             {
              public string path;

              public INIFile(string INIPath)
              {
               path = INIPath;
              }

              [DllImport("kernel32")]
              private static extern long WritePrivateProfileString(string section,string key,string val,string filePath);

              [DllImport("kernel32")]
              private static extern int GetPrivateProfileString(string section,string key,string def, StringBuilder retVal,int size,string filePath);

             
              [DllImport("kernel32")]
              private static extern int GetPrivateProfileString(string section, string key, string defVal, Byte[] retVal, int size, string filePath);


              /// <summary>
              /// 寫INI文件
              /// </summary>
              /// <param name="Section"></param>
              /// <param name="Key"></param>
              /// <param name="Value"></param>
              public void IniWriteValue(string Section,string Key,string Value)
              {
               WritePrivateProfileString(Section,Key,Value,this.path);
              }

              /// <summary>
              /// 讀取INI文件
              /// </summary>
              /// <param name="Section"></param>
              /// <param name="Key"></param>
              /// <returns></returns>
              public string IniReadValue(string Section,string Key)
              {
               StringBuilder temp = new StringBuilder(255);
               int i = GetPrivateProfileString(Section,Key,"",temp, 255, this.path);
               return temp.ToString();
              }
              public byte[] IniReadValues(string section, string key)
              {
               byte[] temp = new byte[255];
               int i = GetPrivateProfileString(section, key, "", temp, 255, this.path);
               return temp;

              }


              /// <summary>
              /// 刪除ini文件下所有段落
              /// </summary>
              public void ClearAllSection()
              {
               IniWriteValue(null,null,null);
              }
              /// <summary>
              /// 刪除ini文件下personal段落下的所有鍵
              /// </summary>
              /// <param name="Section"></param>
              public void ClearSection(string Section)
              {
               IniWriteValue(Section,null,null);
              }

             }


            }

            posted on 2010-10-20 11:21 wrh 閱讀(3374) 評論(0)  編輯 收藏 引用

            導航

            <2010年5月>
            2526272829301
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            統計

            常用鏈接

            留言簿(19)

            隨筆檔案

            文章檔案

            收藏夾

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            国产精品久久久久AV福利动漫| 久久人人爽爽爽人久久久| 久久99精品国产麻豆| 国产成人久久精品一区二区三区| 午夜精品久久久久久久久| 久久99国产精品久久99果冻传媒| 91久久精品电影| 久久人妻AV中文字幕| 狠狠色丁香婷婷久久综合不卡| 亚洲人成无码久久电影网站| 久久亚洲春色中文字幕久久久| 国产99久久久久久免费看| 久久夜色精品国产www| 久久人爽人人爽人人片AV| 久久综合精品国产一区二区三区| 69国产成人综合久久精品| 久久91精品综合国产首页| 国产精品免费看久久久| 久久久精品视频免费观看| 久久精品九九亚洲精品| 香蕉久久夜色精品国产尤物| 国内精品久久人妻互换| 久久夜色精品国产亚洲| 久久久久噜噜噜亚洲熟女综合| 伊人久久精品线影院| 久久无码人妻一区二区三区| 久久久久免费精品国产| 久久99热这里只有精品66| 久久免费视频观看| 久久精品www人人爽人人| 久久精品国产亚洲AV香蕉| 久久久久亚洲AV成人网| 欧美精品一本久久男人的天堂| 日本精品久久久中文字幕| 久久久91精品国产一区二区三区| 丁香五月网久久综合| 久久无码人妻一区二区三区 | 欧美精品一区二区久久| 色综合久久久久网| 久久婷婷久久一区二区三区| 精品久久久久久久|