{"id":71500,"date":"2026-02-03T21:32:46","date_gmt":"2026-02-03T13:32:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/71500.html"},"modified":"2026-02-03T21:32:46","modified_gmt":"2026-02-03T13:32:46","slug":"c-%e5%85%b3%e4%ba%8e%e8%81%94%e5%90%88%e7%bc%96%e7%a8%8b%e5%9f%ba%e7%a1%80","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/71500.html","title":{"rendered":"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840"},"content":{"rendered":"<h2><span style=\"color:#4da8ee\">\u8054\u5408\u7f16\u7a0b<\/span><\/h2>\n<hr \/>\n<h4>\u4e00&#xff0c;setting\u6570\u636e\u5b58\u50a8\u65b9\u5f0f<\/h4>\n<h4><\/h4>\n<h4>1,\u6301\u4e45\u5316\u5b58\u50a8\u65b9\u5f0f&#xff1a;<\/h4>\n<h4>json\u683c\u5f0f\u5b58\u50a8{&#034;age&#034;:10} \u3001<\/h4>\n<h4>file\u6587\u4ef6\u5b58\u50a8\u65b9\u5f0f&#xff08;File \u3001StreamReader)<\/h4>\n<h4>\u4e8c\u8fdb\u5236\u5b58\u50a8\u65b9\u5f0f<\/h4>\n<h4>csv\u5b58\u50a8\u683c\u5f0f\u00a0 \u00a0\u59d3\u540d&#xff0c;\u5e74\u9f84<\/h4>\n<h4>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u5f20\u4e09\u00a0 \u00a0&#xff0c; 10<\/h4>\n<h4>Setting\u5b58\u50a8\u65b9\u5f0f&#xff08;ini\u5b58\u50a8\u683c\u5f0f&#xff09;[net]<\/h4>\n<h4>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 IP &#061; 127.0.0.1<\/h4>\n<h4>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0port&#061;8080<\/h4>\n<h4>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0[data]<\/h4>\n<h4>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u4f59\u4f1f &#061;20<\/h4>\n<h4>xml\u5b58\u50a8\u65b9\u5f0f<\/h4>\n<h4>\u6570\u636e\u5e93\u5b58\u50a8\u65b9\u5f0f<\/h4>\n<h4>\u5185\u5b58\u5b58\u50a8&#xff1a; \u6570\u636e\u7c7b\u578b\u5b58\u50a8\u65b9\u5f0f \u6570\u7ec4\u3001\u5b57\u5178\u3001\u96c6\u5408\u7b49<\/h4>\n<h4><\/h4>\n<\/p>\n<hr \/>\n<\/p>\n<p>2&#xff0c;&#xff0c;\u6253\u5f00\u9875\u9762&#8211;&gt;\u70b9\u51fbSettings.settings<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"410\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133244-6981f8fcb1d14.png\" width=\"1044\" \/><\/p>\n<h4>\u63a5\u7740\u5728winform\u4e2d\u6dfb\u52a0\u5982\u4e0b\u63a7\u4ef6<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"444\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133244-6981f8fce4dad.png\" width=\"967\" \/><\/p>\n<h4>\u5728\u5b58\u50a8\u6309\u94ae\u4e0b\u5199\u4e0b\u5982\u4e0b\u4ee3\u7801&#xff1a;<\/h4>\n<h4>\u5b58\u50a8\u6570\u636e<\/h4>\n<p>\u00a0private void button1_Click(object sender, EventArgs e)<br \/>\n\u00a0{<br \/>\n\u00a0 \u00a0\u00a0Settings set &#061; Settings.Default;\/\/ \u83b7\u53d6\u914d\u7f6e\u5bf9\u8c61<br \/>\n\u00a0 \u00a0 \u00a0set.name &#061; textBox1.Text; \/\/ \u7ed9setting\u914d\u7f6e\u8868\u4e2d\u5bf9\u5e94\u5c5e\u6027\u8fdb\u884c\u8d4b\u503c<br \/>\n\u00a0 \u00a0 \u00a0set.age &#061; int.Parse( textBox2.Text);<br \/>\n\u00a0 \u00a0 \u00a0set.weight &#061; float.Parse( textBox3.Text);<br \/>\n\u00a0 \u00a0 \u00a0set.sex &#061; bool.Parse(textBox4.Text);<br \/>\n\u00a0 \u00a0 \u00a0set.Save();\/\/ \u4fdd\u5b58\u66f4\u6539<br \/>\n\u00a0}<\/p>\n<h4>\u8bfb\u53d6\u6570\u636e&#xff1a;<\/h4>\n<p>\u00a0private void button2_Click(object sender, EventArgs e)<br \/>\n\u00a0{<br \/>\n\u00a0 \u00a0 \u00a0Settings settings &#061; Settings.Default;<br \/>\n\u00a0 \u00a0 \u00a0string name &#061; settings.name;\/\/ \u83b7\u53d6\u914d\u7f6e\u8868\u6570\u636e<br \/>\n\u00a0 \u00a0 \u00a0int age &#061; settings.age;<br \/>\n\u00a0 \u00a0 \u00a0float weight &#061; settings.weight;<br \/>\n\u00a0 \u00a0 \u00a0bool \u00a0sex &#061; settings.sex;<br \/>\n\u00a0 \u00a0 \u00a0richTextBox1.Text &#061; name&#043;&#034;\\\\n&#034;&#043;age&#043;&#034;\\\\n&#034;&#043;weight&#043;&#034;\\\\n&#034;&#043;sex;<\/p>\n<p>\u00a0}<\/p>\n<hr \/>\n<h4>\u4e8c&#xff0c;ini\u6587\u4ef6\u5b58\u50a8\u548c\u8bfb\u53d6<\/h4>\n<h4>1&#xff0c;\u5148\u5728\u684c\u9762\u521b\u5efa\u4e00\u4e2atxt\u6587\u6863&#xff0c;\u540e\u7f00\u540d\u6539\u4e3aini\u683c\u5f0f&#xff0c;\u7f16\u7801\u6539\u6210ANSI\u683c\u5f0f<\/h4>\n<h4>2&#xff0c;\u5728winform\u754c\u9762\u8bbe\u7f6e\u5982\u4e0b\u63a7\u4ef6<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"403\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133245-6981f8fd0ec1b.png\" width=\"705\" \/><\/p>\n<h4>3&#xff0c;\u5728\u8bfb\u53d6\u6309\u94ae\u4e0b\u5199\u5982\u4e0b\u4ee3\u7801<\/h4>\n<p>\u00a0private void button1_Click(object sender, EventArgs e)<br \/>\n\u00a0{<\/p>\n<p>\u00a0 \u00a0 \u00a0\/\/1 \u83b7\u53d6\u6240\u6709\u7684\u8282\u70b9\u540d\u79f0<br \/>\n\u00a0 \u00a0 \u00a0\/\/string[] s1 &#061; \u00a0IniAPI.INIGetAllSectionNames(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;);<br \/>\n\u00a0 \u00a0 \u00a0\/\/foreach (string item in s1)<br \/>\n\u00a0 \u00a0 \u00a0\/\/{<br \/>\n\u00a0 \u00a0 \u00a0\/\/ \u00a0 \u00a0richTextBox1.Text &#043;&#061; item &#043; &#034;\\\\n&#034;;<br \/>\n\u00a0 \u00a0 \u00a0\/\/}<\/p>\n<p>\u00a0 \u00a0 \u00a0\/\/2 \u83b7\u53d6\u6240\u6709\u7684items<br \/>\n\u00a0 \u00a0 \u00a0\/\/string[] s1 &#061; IniAPI.INIGetAllItems(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;,&#034;net&#034;);<br \/>\n\u00a0 \u00a0 \u00a0\/\/foreach (string item in s1)<br \/>\n\u00a0 \u00a0 \u00a0\/\/{<br \/>\n\u00a0 \u00a0 \u00a0\/\/ \u00a0 \u00a0richTextBox1.Text &#043;&#061; item &#043; &#034;\\\\n&#034;;<br \/>\n\u00a0 \u00a0 \u00a0\/\/}<\/p>\n<p>\u00a0 \u00a0 \u00a0\/\/3 \u83b7\u53d6\u5bf9\u5e94\u8282\u70b9\u7684\u952e\u7684\u503c (\u91cd\u8981)<br \/>\n\u00a0 \u00a0 \u00a0string s1 &#061; IniAPI.INIGetStringValue(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;, &#034;data&#034;,&#034;\u82b1\u751f&#034;,&#034;&#034;);<br \/>\n\u00a0 \u00a0 \u00a0\/\/ richTextBox1.Text &#043;&#061; s1 &#043; &#034;\\\\n&#034;;<\/p>\n<p>\u00a0 \u00a0 \u00a0\/\/ 4 \u83b7\u53d6\u5bf9\u5e94\u8282\u70b9\u7684\u952e\u7684\u503c(\u6574\u578b)<br \/>\n\u00a0 \u00a0 \u00a0int a1 &#061; \u00a0IniAPI.GetPrivateProfileInt(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;, &#034;data&#034;, &#034;\u7ea2\u8c46&#034;, 0);<br \/>\n\u00a0 \u00a0 \u00a0richTextBox1.Text &#043;&#061; a1 &#043; &#034;\\\\n&#034;;<br \/>\n\u00a0}<\/p>\n<\/p>\n<p>4&#xff0c;\u5728\u5199\u5165\u6309\u94ae\u4e0b\u5199\u5982\u4e0b\u4ee3\u7801<\/p>\n<p>\u00a0private void button2_Click(object sender, EventArgs e)<br \/>\n\u00a0{<br \/>\n\u00a0 \u00a0 \u00a0\/\/1 \u5199\u5165\u6307\u5b9a\u8282\u70b9\u6307\u5b9a\u7684\u952e (\u91cd\u70b9)<br \/>\n\u00a0 \u00a0 \u00a0IniAPI.INIWriteValue(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;, &#034;data&#034;, &#034;\u9ec4\u8c46&#034;, &#034;10&#034;);<\/p>\n<p>\n\u00a0 \u00a0 \u00a0\/\/2 \u5220\u9664\u8282\u70b9<br \/>\n\u00a0 \u00a0 \u00a0\/\/IniAPI.INIDeleteSection(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;, &#034;data&#034;);<\/p>\n<p>\u00a0 \u00a0 \u00a0\/\/3 \u5220\u9664\u952e<br \/>\n\u00a0 \u00a0 \u00a0\/\/IniAPI.INIDeleteKey(&#064;&#034;C:\\\\Users\\\\Administrator\\\\Desktop\\\\3.ini&#034;, &#034;net&#034;, &#034;port&#034;);<\/p>\n<p>\u00a0}<\/p>\n<hr \/>\n<h4>\u4e09&#xff0c;\u56fe\u7247\u7684\u8bfb\u5199\u64cd\u4f5c<\/h4>\n<h4>1&#xff0c;\u4f7f\u7528CogImageFileTool \u8fdb\u884c\u8bfb\u53d6\u56fe\u7247<\/h4>\n<h4>2&#xff0c;cogRecordDisplay1 \u5c55\u793a\u8bb0\u5f55\u7684 \u4e5f\u53ef\u4ee5\u5c55\u793a\u56fe\u7247<\/h4>\n<h4>3&#xff0c;\u5728winform\u6dfb\u52a0\u5982\u4e0b\u63a7\u4ef6<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"657\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133245-6981f8fd1fb0b.png\" width=\"1133\" \/><\/p>\n<h3>\u5728\u6309\u94ae1\u4e0b\u8f93\u5165&#xff1a;<\/h3>\n<p>\u00a0private void button1_Click(object sender, EventArgs e)<br \/>\n\u00a0{<br \/>\n\u00a0 \u00a0 \u00a0\/\/1 \u521b\u5efaCogImageFileTool\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0CogImageFileTool fileTool &#061; new CogImageFileTool();\u00a0<br \/>\n\u00a0 \u00a0 \u00a0OpenFileDialog dia &#061; new OpenFileDialog(); \/\/ \u6587\u4ef6\u5bf9\u8bdd\u6846<br \/>\n\u00a0 \u00a0 \u00a0dia.Filter &#061; &#034;All Image Files| *.jpg; *.png; *.jpeg; *.ico; *.tif; *.tiff; *.idb; *.bmp&#034;;<br \/>\n\u00a0 \u00a0 \u00a0dia.Title &#061; &#034;\u8bf7\u9009\u62e9\u6587\u4ef6&#034;;<br \/>\n\u00a0 \u00a0 \u00a0if (dia.ShowDialog()&#061;&#061;DialogResult.OK)<br \/>\n\u00a0 \u00a0 \u00a0{<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ \u53ef\u4ee5\u83b7\u53d6\u9009\u62e9\u6587\u4ef6\u8def\u5f84<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ fileTool.Operator.Open \u6253\u5f00fileTool\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u53c2\u65701 \u00a0\u8def\u5f84<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/\u53c2\u65702 \u00a0\u8bfb\u53d6fileTool\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/2 \u4f7f\u7528fileTool\u5de5\u5177\u8bfb\u53d6\u56fe\u7247<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0fileTool.Operator.Open(dia.FileName,CogImageFileModeConstants.Read);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/3 \u8fd0\u884c\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0fileTool.Run();<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/4 \u83b7\u53d6\u8f93\u51fa\u56fe \u5c55\u793a<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0cogRecordDisplay1.Image&#061;fileTool.OutputImage;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/5 \u81ea\u9002\u5e94\u5927\u5c0f<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0cogRecordDisplay1.Fit();<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0\u00a0<br \/>\n\u00a0 \u00a0 \u00a0}<\/p>\n<\/p>\n<h3>\u5728\u6309\u94ae2\u4e0b\u8f93\u5165&#xff1a;<\/h3>\n<p>\u00a0 private void button2_Click(object sender, EventArgs e)<br \/>\n\u00a0 {\u00a0<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0CogImageFileTool fileTool &#061; new CogImageFileTool();<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u4fdd\u5b58\u63a7\u4ef6\u5c55\u793a\u7684\u56fe\u7247<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \/\/ \u628a\u63a7\u4ef6\u56fe\u7247\u8d4b\u503c\u7ed9\u5de5\u5177\u7684\u8f93\u5165\u56fe\u53c2\u6570\u4e2d<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 fileTool.InputImage &#061; cogRecordDisplay1.Image;<\/p>\n<p>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ fileTool.Operator.Open \u6253\u5f00fileTool\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u53c2\u65701 \u00a0\u8def\u5f84<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u53c2\u65702 \u00a0\u5199\u5165fileTool\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/2 \u4f7f\u7528fileTool\u5de5\u5177\u5199\u5165\u56fe\u7247<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fileTool.Operator.Open(&#064;&#034;1.png&#034;, CogImageFileModeConstants.Write);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/3 \u8fd0\u884c\u5de5\u5177<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 fileTool.Run();<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/4 \u83b7\u53d6\u8f93\u51fa\u56fe \u5c55\u793a<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\/\/ cogRecordDisplay1.Image &#061; fileTool.OutputImage;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/5 \u81ea\u9002\u5e94\u5927\u5c0f<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/5 \u81ea\u9002\u5e94\u5927\u5c0f<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/cogRecordDisplay1.Fit(); \u00a0\u00a0<\/p>\n<p>\u00a0 }<br \/>\n\u00a0<\/p>\n<\/p>\n<h3>\u5728\u6309\u94ae3\u4e0b\u8f93\u5165&#xff1a;<\/h3>\n<p>\u00a0 \u00a0private void button3_Click(object sender, EventArgs e)<br \/>\n\u00a0 \u00a0{<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0OpenFileDialog dia &#061; new OpenFileDialog(); \/\/ \u6587\u4ef6\u5bf9\u8bdd\u6846<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0dia.Filter &#061; &#034;All Image Files| *.jpg; *.png; *.jpeg; *.ico; *.tif; *.tiff; *.idb; *.bmp&#034;;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0dia.Title &#061; &#034;\u8bf7\u9009\u62e9\u6587\u4ef6&#034;;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0if (dia.ShowDialog() &#061;&#061; DialogResult.OK)<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0{<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Bitmap bit &#061; \u00a0Image.FromFile(dia.FileName) as Bitmap; \/\/\u8bfb\u53d6\u672c\u5730\u56fe\u7247\u8f6c\u6210\u4f4d\u56fe<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ CogImage8Grey image &#061; new CogImage8Grey(bit); \/\/\u8f6c\u62108\u4f4d\u7684\u7070\u56fe<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0CogImage24PlanarColor image &#061; new CogImage24PlanarColor(bit);\/\/\u628a\u56fe\u7247\u8f6c\u6210\u5f69\u56fe<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0cogRecordDisplay1.Image &#061; image; \/\/\u5c55\u793a\u56fe\u7247<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0cogRecordDisplay1.Fit();<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0}<\/p>\n<p>\n\u00a0 \u00a0}<\/p>\n<\/p>\n<h3>\u5728\u6309\u94ae4\u4e0b\u8f93\u5165&#xff1a;<\/h3>\n<p>\u00a0 \/\/\u4f7f\u7528\u4f4d\u56fe\u8fdb\u884c\u5199\u5165\u4fdd\u5b58<br \/>\n\u00a0 private void button4_Click(object sender, EventArgs e)<br \/>\n\u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 string path &#061; \u00a0 Directory.GetCurrentDirectory()&#043;&#034;\\\\\\\\data&#034;;<br \/>\n\u00a0 \u00a0 \u00a0 if (!Directory.Exists(path)) \u00a0 \u00a0<br \/>\n\u00a0 \u00a0 \u00a0 {<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Directory.CreateDirectory(path);<br \/>\n\u00a0 \u00a0 \u00a0 }<br \/>\n\u00a0 \u00a0 \u00a0 \/\/CreateContentBitmap \u521b\u5efa\u4f4d\u56fe\u5185\u5bb9<br \/>\n\u00a0 \u00a0 \u00a0 \/\/\u53c2\u65701 Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Image \u4ec5\u4ec5\u628a\u56fe\u7247\u8f6c\u6210\u4f4d\u56fe\u4e86<br \/>\n\u00a0 \u00a0 \u00a0 Bitmap map &#061; cogRecordDisplay1.CreateContentBitmap(Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Image) as Bitmap;<br \/>\n\u00a0 \u00a0 \u00a0 map.Save(path &#043; $&#034;\\\\\\\\{DateTime.Now:yyyyMMddhhmmss}.png&#034;);<\/p>\n<p>\u00a0 }<\/p>\n<\/p>\n<hr \/>\n<h3>\u56db&#xff0c; \u52a0\u8f7d\u5355\u4e2aPMA\u5de5\u5177<\/h3>\n<h4>1&#xff0c;\u5148\u5728winform\u754c\u9762\u52a0\u5165\u4ee5\u4e0b\u63a7\u4ef6<\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"724\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133245-6981f8fd62c31.png\" width=\"1422\" \/><\/p>\n<h3>2&#xff0c;\u7a97\u4f53\u7684\u52a0\u8f7d\u4e8b\u4ef6<\/p>\n<p>CogPMAlignTool pma;<br \/>\nprivate void Form1_Load(object sender, EventArgs e)<br \/>\n{<br \/>\n\u00a0 \u00a0 \/\/\u52a0\u8f7dvpp\u8d44\u6e90(\u91cd\u70b9)<br \/>\n\u00a0 \u00a0 pma &#061; CogSerializer.LoadObjectFromFile(&#034;\u6a21\u7248\u5339\u914d.vpp&#034;) as CogPMAlignTool;<br \/>\n\u00a0 \u00a0 \/\/Subject \u5c5e\u6027 &#xff0c;\u5de5\u5177\u5c55\u793a\u5185\u5bb9<br \/>\n\u00a0 \u00a0 cogPMAlignEditV21.Subject &#061; pma;<br \/>\n\u00a0 \u00a0 \/\/MessageBox.Show(&#034;\u52a0\u8f7d\u8d44\u6e90\u6210\u529f&#034;);<br \/>\n}<\/h3>\n<\/p>\n<h3>3&#xff0c;\u5728\u6309\u94ae1\u4e0b\u5199\u5165&#xff1a;<\/h3>\n<p>\u00a0private void button1_Click(object sender, EventArgs e)<br \/>\n\u00a0{<\/p>\n<p>\u00a0 \u00a0 \u00a0if (pma&#061;&#061;null)<br \/>\n\u00a0 \u00a0 \u00a0{<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0MessageBox.Show(&#034;\u52a0\u8f7d\u8d44\u6e90\u5931\u8d25&#034;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0return;<br \/>\n\u00a0 \u00a0 \u00a0}<br \/>\n\u00a0 \u00a0 \u00a0OpenFileDialog dia &#061; new OpenFileDialog(); \/\/ \u6587\u4ef6\u5bf9\u8bdd\u6846<br \/>\n\u00a0 \u00a0 \u00a0dia.Filter &#061; &#034;All Image Files| *.jpg; *.png; *.jpeg; *.ico; *.tif; *.tiff; *.idb; *.bmp&#034;;<br \/>\n\u00a0 \u00a0 \u00a0dia.Title &#061; &#034;\u8bf7\u9009\u62e9\u6587\u4ef6&#034;;<br \/>\n\u00a0 \u00a0 \u00a0if (dia.ShowDialog() &#061;&#061; DialogResult.OK)<br \/>\n\u00a0 \u00a0 \u00a0{<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 Bitmap map &#061; Image.FromFile(dia.FileName) as Bitmap; \/\/\u52a0\u8f7d\u8def\u5f84\u8d44\u6e90<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 pma.InputImage &#061; new CogImage8Grey(map);\/\/\u8f6c\u62108\u4f4d\u7684\u7070\u56fe,\u8d4b\u503c\u7ed9pma\u7684\u8f93\u5165\u56fe\u7247<\/p>\n<p>\u00a0 \u00a0 \u00a0}<\/p>\n<p>\u00a0}<\/p>\n<\/p>\n<h3>4&#xff0c;\u5728\u6309\u94ae2\u5199\u5165&#xff1a;<\/h3>\n<\/p>\n<p>\u00a0\/\/ \u8fd0\u884c<br \/>\n\u00a0private void button2_Click(object sender, EventArgs e)<br \/>\n\u00a0{<br \/>\n\u00a0 \u00a0 \u00a0if(pma&#061;&#061;null)<br \/>\n\u00a0 \u00a0 \u00a0{<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0MessageBox.Show(&#034;\u52a0\u8f7d\u8d44\u6e90\u5931\u8d25&#034;);<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0return;<br \/>\n\u00a0 \u00a0 \u00a0}<\/p>\n<p>\u00a0 \u00a0 \u00a0pma.Run();\/\/ \u8fd0\u884c<\/p>\n<p>\n\u00a0 \u00a0 \u00a0\/\/\u5c55\u793a\u4e00\u6761\u8bb0\u5f55<br \/>\n\u00a0 \u00a0 \u00a0\/\/pma.CreateLastRunRecord() \u521b\u5efa\u4e0a\u4e00\u6b21\u7684\u8fd0\u884c\u8bb0\u5f55<br \/>\n\u00a0 \u00a0 \u00a0\/\/SubRecords \u5b50\u8bb0\u5f55<br \/>\n\u00a0 \u00a0 \u00a0cogRecordDisplay1.Record &#061; pma.CreateLastRunRecord().SubRecords[0];<br \/>\n\u00a0 \u00a0 \u00a0cogRecordDisplay1.Fit();<\/p>\n<p>\u00a0}<\/p>\n<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8054\u5408\u7f16\u7a0b\u4e00&#xff0c;setting\u6570\u636e\u5b58\u50a8\u65b9\u5f0f1,\u6301\u4e45\u5316\u5b58\u50a8\u65b9\u5f0f&#xff1a;json\u683c\u5f0f\u5b58\u50a8{\\&#8221;age\\&#8221;:10} \u3001file\u6587\u4ef6\u5b58\u50a8\u65b9\u5f0f&#xff08;File \u3001StreamReader)\u4e8c\u8fdb\u5236\u5b58\u50a8\u65b9\u5f0fcsv\u5b58\u50a8\u683c\u5f0f\u00a0 \u00a0\u59d3\u540d&#xff0c;\u5e74\u9f84\u5f20\u4e09\u00a0 \u00a0&#xff0c; 10Setting\u5b58\u50a8\u65b9\u5f0f&#xff08;ini\u5b58\u50a8\u683c\u5f0f&#xff09;[net]IP  127.0.0.1port8080[data]\u4f59\u4f1f 20xml\u5b58\u50a8\u65b9\u5f0f\u6570\u636e\u5e93\u5b58\u50a8\u65b9\u5f0f\u5185\u5b58\u5b58\u50a8&amp;#xff1<\/p>\n","protected":false},"author":2,"featured_media":71495,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7515,55,790,190],"topic":[],"class_list":["post-71500","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-vision-pro","tag-c","tag-visual-studio","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/71500.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u8054\u5408\u7f16\u7a0b\u4e00&#xff0c;setting\u6570\u636e\u5b58\u50a8\u65b9\u5f0f1,\u6301\u4e45\u5316\u5b58\u50a8\u65b9\u5f0f&#xff1a;json\u683c\u5f0f\u5b58\u50a8{&quot;age&quot;:10} \u3001file\u6587\u4ef6\u5b58\u50a8\u65b9\u5f0f&#xff08;File \u3001StreamReader)\u4e8c\u8fdb\u5236\u5b58\u50a8\u65b9\u5f0fcsv\u5b58\u50a8\u683c\u5f0f\u00a0 \u00a0\u59d3\u540d&#xff0c;\u5e74\u9f84\u5f20\u4e09\u00a0 \u00a0&#xff0c; 10Setting\u5b58\u50a8\u65b9\u5f0f&#xff08;ini\u5b58\u50a8\u683c\u5f0f&#xff09;[net]IP 127.0.0.1port8080[data]\u4f59\u4f1f 20xml\u5b58\u50a8\u65b9\u5f0f\u6570\u636e\u5e93\u5b58\u50a8\u65b9\u5f0f\u5185\u5b58\u5b58\u50a8&amp;#xff1\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/71500.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-03T13:32:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133244-6981f8fcb1d14.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/71500.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/71500.html\",\"name\":\"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-03T13:32:46+00:00\",\"dateModified\":\"2026-02-03T13:32:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/71500.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/71500.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/71500.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/71500.html","og_locale":"zh_CN","og_type":"article","og_title":"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u8054\u5408\u7f16\u7a0b\u4e00&#xff0c;setting\u6570\u636e\u5b58\u50a8\u65b9\u5f0f1,\u6301\u4e45\u5316\u5b58\u50a8\u65b9\u5f0f&#xff1a;json\u683c\u5f0f\u5b58\u50a8{\"age\":10} \u3001file\u6587\u4ef6\u5b58\u50a8\u65b9\u5f0f&#xff08;File \u3001StreamReader)\u4e8c\u8fdb\u5236\u5b58\u50a8\u65b9\u5f0fcsv\u5b58\u50a8\u683c\u5f0f\u00a0 \u00a0\u59d3\u540d&#xff0c;\u5e74\u9f84\u5f20\u4e09\u00a0 \u00a0&#xff0c; 10Setting\u5b58\u50a8\u65b9\u5f0f&#xff08;ini\u5b58\u50a8\u683c\u5f0f&#xff09;[net]IP 127.0.0.1port8080[data]\u4f59\u4f1f 20xml\u5b58\u50a8\u65b9\u5f0f\u6570\u636e\u5e93\u5b58\u50a8\u65b9\u5f0f\u5185\u5b58\u5b58\u50a8&amp;#xff1","og_url":"https:\/\/www.wsisp.com\/helps\/71500.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-03T13:32:46+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/02\/20260203133244-6981f8fcb1d14.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/71500.html","url":"https:\/\/www.wsisp.com\/helps\/71500.html","name":"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-03T13:32:46+00:00","dateModified":"2026-02-03T13:32:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/71500.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/71500.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/71500.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C# \u5173\u4e8e\u8054\u5408\u7f16\u7a0b\u57fa\u7840"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/71500","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=71500"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/71500\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/71495"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=71500"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=71500"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=71500"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=71500"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}