IniFile简单读写类

IniFile.cs:C#来操作ini配置文件 其实,不用那么麻烦的自己写程序去读取和写入ini配置文件,直接调用API就好了。 点击此处下载全部源程序IniFile.cs 【下载说明】 1、单击上面这个地址,打开下载页面。 2、点普通下载--等待30秒--点“下载”按钮--保存 主要源程序: using System; using System.IO; using System.Runtime.InteropService 阅读详情
 
using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices;



namespace WWBClassLib.Tools

{

    public class IniFile

    {



        public string path;







        [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);







        /// <summary>



        /// INIFile 构造函数.



        /// </summary>



        /// <PARAM name="INIPath"></PARAM>



        public IniFile(string INIPath)

        {



            path = INIPath;



        }



        /// <summary>



        /// 写入IniFile



        /// </summary>



        /// <PARAM name="Section"></PARAM>



        /// Section name



        /// <PARAM name="Key"></PARAM>



        /// Key Name



        /// <PARAM name="Value"></PARAM>



        /// Value Name



        public void IniWriteValue(string Section, string Key, string Value)

        {



            WritePrivateProfileString(Section, Key, Value, this.path);



        }







        /// <summary>



        /// 读取IniFile



        /// </summary>



        /// <PARAM name="Section"></PARAM>



        /// <PARAM name="Key"></PARAM>



        /// <PARAM name="Path"></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();







        }



    }

}

C#实现操作INI文件 (附完整源码) 阅读详情

相关推荐

asp.net读写ini文件

asp.net读写ini文件内容

一个用ASP读取INI文件的VBScript类

全部源代码如下: 显示源码 1 Class INIClass 2 Private dict,path 3 4 Private Sub Class_Initialize() 5 Set dict=server.CreateObject("Scripting.Dictionary") 6 End Sub 7 Private Su...

weixin_33709364的博客 183

C# .net读取ini配置文件

C# .net读取ini配置文件

ASP读取ini文件的实现方法

INI是微软Windows操作系统中的文件扩展名。这些字母表示初始化。正如该术语所表示的,INI文件被用来对操作系统或特定程序初始化或进行参数设置。ini文件可以存储很多数据,用来配置应用软件以实现不同用户的要求,那如何用ASP来读取ini文件呢?聚友提供一段代码,可以通过这段代码来实现读取ini文件,代码如下: "" then 'There is data on this line if left(

魔拉宝 3291

ASP读写INI文件

ASP读写INI文件的函数,完全封装,加入包含文件即可使用。

asp.net读写ini文件最简单的代码

asp.net读写ini文件,里面有个ini.cs类文件,下载后,可以放app_Code里调用声明下,就可以使用了,代码很简单,可以自己看下里面,里面有写了说明文件

一起谈.NET技术,asp.net程序来读取多语言版本Ini配置文件

  这是asp.net程序来读取多语言版本Ini配置文件的开发示例,主要分为以下三个部分:   1、 Ini 配置文件   2、 读取Ini配置文件的DLL   3、 Web页面调用与内容显示   4、 数据库表T_User,如右图    首先说明一下Ini 文件格式:如下图其中[M_Index]节点和该节点下的所有的key和value,其中[M_Index]节点的名称是对应开发示例中的每个页面...

weixin_33834075的博客 159

头歌MySQL数据库实训答案 有目录

头歌java实训答案集数据库部分一条一条的写,可鼠标手动粘贴,除特定命令外未分大小写。 第1关:创建数据库 第2关创建表 第3关:使用主键约束 第4关:外键约束 第5关:添加常用约束 MySQL数据库 - 数据库和表的基本操作(一) 第1关:查看表结构与修改表名 第2关:修改字段名与字段数据类型 第3关:添加与删除字段 第4关:修改字段的排列位置 第5关:删除表的外键约束 MySQL数据库 - 数据库和表的基本操作(二) 第1关:插入数据 第2关:更新数据 第3关:删除数据 MySQL数据库 - 单表查询(

m0_67401761的博客 4万+

关于C#操作INI文件的总结

INI文件其实是一种具有特定结构的文本文件,它的构成分为三部分,结构如下: [Section1] key 1 = value2 key 1 = value2 …… [Section2] key 1 = value1 key 2 = value2 …… 文件由若干个段落(section)组成,每个段落又分成若干个键(key)和值(value)。Windows系统自带的Win32

l653423909的专栏 449

PX4无人机实战:手把手教你用MAVROS实现Offboard模式(附避坑指南)

本文提供了一份详尽的PX4无人机Offboard模式实战指南,重点解析了如何通过MAVROS实现从仿真到实机的控制。内容涵盖硬件连接、串口权限设置、MAVROS配置、核心代码编写以及实机操作全流程,并附有详细的避坑指南和故障排查手册,帮助开发者快速掌握ROS与PX4飞控的集成开发。

weixin_29172201的博客 273

全新RGB-D及平面法线数据集DIODE

丰田工业大学联合芝加哥大学和北航发布全新RGB-D及平面法线数据集 DIODE (Dense Indoor and Outdoor DEpth)。

qq_43477338的博客 1543

C#中读写ini文件

using System;using System.Runtime.InteropServices;using System.Text; namespace Ini...{    /**////     /// Create a New INI file to store or load data    ///     public class IniFile    ...{        p

LeoMaya 897

统信UOS服务器上,达梦DM8数据库安装避坑全记录(附大小写敏感设置)

本文详细介绍了在统信UOS服务器版上部署达梦DM8数据库的全过程,包括环境准备、安装流程、数据库实例初始化及关键参数配置,特别是大小写敏感设置的注意事项。提供了从系统配置到性能优化的完整指南,帮助用户避免常见问题,确保数据库稳定运行。

weixin_30647423的博客 340

C# 写参数至配置文件

1 调用系统API: [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); [DllImport("kernel32")] private static extern int GetPrivateProfileString(string secti

m0_51680012的博客 800

PLC凸轮开关指令编程应用——控制算法

凸轮开关指令的作用是在PLC程序中根据凸轮开关(Cam Switch)的状态执行不同的操作。凸轮开关通常是机械式的开关装置,它的位置会随着机械运动的变化而改变。凸轮开关的状态可以用来检测机器的位置、角度或其他相关信息,从而触发相应的控制动作。总结起来,凸轮开关指令是PLC编程中常用的一种控制算法,通过检测凸轮开关的状态来触发相应的操作。本文将介绍凸轮开关指令的应用和相应的控制算法,并提供相关的源代码示例。在这个示例中,凸轮开关状态的值代表不同的位置,根据凸轮开关状态的不同,执行相应的动作。

LiJavascript的博客 1036

25、量子计算:中性原子与约瑟夫森结量子比特

本文详细探讨了中性原子和约瑟夫森结两种量子比特在量子计算中的应用。中性原子量子比特利用光晶格实现量子态的操控,具有长相干时间的优势,但面临可扩展性和多量子比特操作的挑战;而约瑟夫森结量子比特基于超导技术,结合半导体制造工艺,具有低耗散和潜在的高可扩展性,但在参数控制和环境干扰方面存在难题。文章还比较了这两种方案的性能、应用场景及未来发展趋势,展望了它们在量子计算发展中的潜力与突破方向。

ol789012的博客 215

C#读取.ini配置文件

C#读取.ini配置文件

花开莫与流年错_的博客 1314

大模型自我认知微调的实战教程

本文主要介绍了大模型自我认知微调的实战教程,希望对学习大语言模型的同学们有所帮助。微调成功并保留原有能力的截图如下所示: 文章目录 1. 前言 2. 配置环境 2.1 安装虚拟环境 2.2 安装依赖库 3. 实战代码 3.1 配置数据集 3.2 lora微调

herosunly的博客 4万+

如何通过 C# 有效的读取 INI 文件?

咨询区 zendar在 .NET 中是否有内置的类可以读取标准的 .ini 文件,文件格式如下:[Section] <keyname>=<value> ...Del...

zls365365的博客 1241

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

QSettings封装成读写配置文件操作类

QSettings封装成读写配置文件操作类

1160

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

matlab中iniFile函数的使用

iniFile 从标准ini(ASCII)创建、读取或写入数据文件。这样的文件被分成若干部分([节名]),小节(用{小节名}括起来),和键(键=值)。空行和第一个非空的字符;(注释行)被忽略。 iniFile(fileName,‘write’,keys,<‘style’>) 写入以字符串的元胞数组给定的键值,可选样式变量:“tabbed”写入节,以标签样式显示子章节和键,以提高 可读性...

qq_40788950的博客 3191

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

android ini文件读写类,android java 读写 ini 文件 工具类

开始用ini4j 挺好用的..功能 很强大地址:http://ini4j.sourceforge.net/使用的时候注意换行问题.不同系统的换行符有些不一样windows下的文本文件换行符:\r\nlinux/unix下的文本文件换行符:\rMac下的文本文件换行符:\n具体表现:在linux下面生成的文件 到 window下面用记事本打开不换行解决办法: ini4j 有 Config 类 ,当...

weixin_28822657的博客 374

VC版的IniFile

1、这个IniFile是参考Delphi的Inifile来实现的。总共包括三个类:CCustomIniFile, CIniFile和CMemIniFile 其中CCustomIniFile是个抽象类,CIniFile和CMemIniFile是两个具体实现 2、CIniFile通过调用WINDOWS的GetPrivateProfileStringA和WritePrivateProfile...

weixin_34378969的博客 134
上一篇: 更新下Excel操作类
下一篇: 常用输入项目验证类
b哈利路亚d
博客等级 码龄20年 597粉丝 460原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值