
c#
liangyely
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
一键解除.resx文件锁定
摘要:该PowerShell脚本用于批量解除指定目录下.resx文件的锁定状态。首先设置项目根路径$folderPath,然后递归获取该路径下所有.resx文件,通过Unblock-File命令逐个解除文件锁定,并输出处理日志。最后显示"所有.resx文件已解除锁定"的完成提示。该脚本适用于需要批量处理被系统锁定的资源文件场景。(99字)原创 2025-06-24 11:42:21 · 74 阅读 · 0 评论 -
阿里云oss文档预览与快照
4:绑定域名,【Bucket配置】->【绑定域名】->需要在域名解析中配置跳转,也可以直接在这个域名绑定页面中选中【2:创建ram授权码:https://ram.console.aliyun.com/overview。1:开通oss,https://oss.console.aliyun.com/overview。3:绑定快照,【数据处理】->【文档处理】->创建绑定project。2:绑定imm,【数据处理】->【智能媒体】->【绑定】阿里云oss做文档预览与快照。原创 2024-04-27 14:09:03 · 1793 阅读 · 0 评论 -
好用的Excel转HTML库
【代码】好用的Excel转HTML库。原创 2024-03-30 05:55:54 · 291 阅读 · 0 评论 -
WPF的TextBox控件中启用拖放操作
这将启用TextBox的拖放功能。原创 2023-11-04 20:42:44 · 634 阅读 · 0 评论 -
net core后台访问外部web api
【代码】net core后台访问外部web api。原创 2023-06-26 00:12:55 · 289 阅读 · 0 评论 -
客户端页面缓存方案
方案一:全局,默认是有缓存,这里设置取消缓存。方案二:缓存指定的action。方案三:缓存指定的action。原创 2022-12-23 13:50:17 · 212 阅读 · 0 评论 -
html中在div元素的asp-validation-summary属性显示提示文本
2、在Filter中间件中:ActionExecutingContext context。原创 2022-11-30 21:35:59 · 492 阅读 · 0 评论 -
WPF使用Task多线程让界面防卡注意事项
Task.Run(() => { for (int i = 0; i < 100; i++) { this.Dispatcher.Invoke(() => { //像带延迟的那种相似代码,绝不能在...原创 2022-01-11 18:12:23 · 1054 阅读 · 0 评论 -
扩展BindingList
让BindingList与List随意结合 public static class BindingListExtension { public static void AddRange<T>(this System.ComponentModel.BindingList<T> d, List<T> data) { foreach (var item in data) { .原创 2022-01-08 21:16:05 · 274 阅读 · 0 评论 -
gRPC Net Core服务器+WPF客户端
1、创建grpc服务器端项目,2、把项目里的greet.proto 文件的属性 gRPC Stub Classes 设置为Client and Server,这样,客户端就可以引用,否则,此前度娘无解,3、greet.proto中的service可以创建多个,例如:service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply); rpc SayHello2 (NameV..原创 2021-12-24 22:16:49 · 1057 阅读 · 0 评论 -
WPF设置菜单文字居中
m.SetValue(TextBlock.TextAlignmentProperty, TextAlignment.Center);SetValue功能很强大,可以设置很多东西原创 2021-12-13 03:32:49 · 2472 阅读 · 0 评论 -
NPOI的WORD填表
public static void Word_FillModel(string modelPath, string savePath, Dictionary<string, string> keyValues) { System.IO.FileStream fs = new System.IO.FileStream(modelPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read.原创 2021-12-08 22:35:33 · 1137 阅读 · 0 评论 -
ProxyKit服务器http反向代理应用
扩展类: public class MyTypedHandler : IProxyHandler { private IConfiguration _upstreamHostLookup; public MyTypedHandler(IConfiguration upstreamHostLookup) { _upstreamHostLookup = upstreamHostLookup; }原创 2020-07-23 19:11:43 · 804 阅读 · 0 评论 -
wpf代码实现绑定数据
((GridView)listview.View).Columns[0].DisplayMemberBinding = new Binding { Path = new PropertyPath("name") }; ((GridView)listview.View).Columns[1].DisplayMemberBinding = new Binding { Path = new PropertyPath("ip") }; ((G...原创 2020-06-26 21:02:59 · 478 阅读 · 0 评论 -
wpf控件显示层次设置
PhoneCode pc = new PhoneCode();pc.OK += Pc_OK;grid.Children.Add(pc);Panel.SetZIndex(pc, grid.Children.Count + 1);原创 2020-05-26 18:25:09 · 3376 阅读 · 0 评论 -
C# WebClient登录与下载文件,带cookie
public class WebClientEx : WebClient { private CookieContainer cookie = new CookieContainer(); protected override WebRequest GetWebRequest(Uri address) { WebRequest request = base.GetWebRequest(a.原创 2020-05-22 18:48:28 · 1252 阅读 · 0 评论 -
wpf动态创建控件并删除(关闭),创建窗口元素容器
private void OpenPhoneNumber() { PhoneNumber p = new PhoneNumber(); p.Margin = new Thickness { Left = 20, Top = 20 }; grid.Children.Add(p); grid.RegisterName("PhoneNumber", p); } ...原创 2020-05-20 17:35:32 · 797 阅读 · 0 评论 -
在c# 7.3中不可用,请使用8.0或更高的语言版本
在工程文件 xxx.csproj 里修改,LangVersion 修改为:preview <PropertyGroup> <LangVersion>preview</LangVersion> </PropertyGroup>或者改为:8.0 <PropertyGroup> <LangVersion>8.0</LangVersion> </PropertyGroup>...原创 2020-05-16 19:10:33 · 20946 阅读 · 4 评论 -
WPF改变窗口尺寸,修改控件尺寸
window中添加SizeChanged事件然后: grid1.Width = this.ActualWidth; grid1.Height = this.ActualHeight; var w = this.ActualWidth - 15; var h = this.ActualHeigh...原创 2020-03-03 18:34:35 · 2423 阅读 · 0 评论 -
C# 线程内调用窗口控件
Action action = () => { this.Title = ""; this.textbox1.Text = "123"; };this.Dispatcher.BeginInvoke(action);//this.textbox1...原创 2020-03-03 16:34:32 · 878 阅读 · 0 评论 -
C#中的lock(锁)应用例子
public IActionResult Privacy(string page) { for (int j = 0; j < 100000; j++) { new System.Threading.Thread((k) => { ...原创 2020-02-13 13:46:22 · 1236 阅读 · 0 评论 -
iis express已经启动该,但是vs提示 无法连接到web服务器 "iis express"
能启动,但是怎么都无法连接web,百度无解,这里发出解决方法,可能是其中的一种情况:在解决方案目录下 Properties内的 launchSettings.json,可能设置了ip如下:"applicationUrl": "http://192.168.1.2",直接将其通通改为:"applicationUrl": "http://localhost", 即可,运行ok。...原创 2019-11-17 22:44:10 · 614 阅读 · 0 评论 -
ASP.NET Core 依赖注入
依赖:类A用到了类B,我们就说类A依赖类B.如果一个类没有任何地方使用到,那这个类基本上可以删掉了.public class Test { private MyDependency md = new MyDependency(); public void Print() { md.Print(); ...转载 2019-03-06 17:10:02 · 209 阅读 · 0 评论 -
IIS配置
现在的iis并不是像十几年前那么好配置,问题一大堆,今天整理一下:1、安装iis,跟十几年前一样方法。安装时候,一定不要忘了两点:iis7 :控制面板-》打开或关闭windows功能-》Internet信息服务-》万维网服务-》应用程序开发功能,勾选上“.net扩展性”和“ASP.NET”,保存后,重启IIS服务器即可。iis8:控制面板-》打开或关闭windows功能-》Int...原创 2019-02-14 14:45:40 · 398 阅读 · 0 评论 -
vs2019创建mvc,自动生成连接数据库Mysql代码
InvalidOperationException: Unable to resolve service for type 'WebApplication3.Models.backtestContext' while attempting to activate 'WebApplication3.Controllers.SysUsersController'.Microsoft.Extensi...原创 2019-02-17 21:51:35 · 9296 阅读 · 1 评论 -
scaffold-dbcontext 命令使用说明
工具的scaffold-dbcontext(数据库上下文脚手架)指令来生成models和context。指令详细介绍:Scaffold-DbContext [-Connection] <String> [-Provider] <String> [-OutputDir <String>] [-Context <String>] [-Schem...转载 2019-02-17 11:55:28 · 7487 阅读 · 1 评论 -
使用ACCESS数据库时出现“操作必须使用一个可更新的查询”的解决办法
如果代码正常,那就是数据库所在的文件夹的权限不够,数据库无法写入,需要给这个文件夹增加写入权限原创 2018-09-28 21:36:42 · 3112 阅读 · 0 评论 -
asp.net mvc中用ViewData或ViewBag传递数据字符防止转义
后台代码:ViewBag.error = @"<h6 style=""color: red"">错误</h6>";前台:@Html.Raw(ViewBag.error)原创 2018-10-07 15:06:05 · 3082 阅读 · 0 评论 -
C#解析JSON
1、打开菜单【项目】,选择【管理NuGet程序包】,搜索 "Newtonsoft" ,并安装,我这里搜索到的是 Newtonsoft.Json.Net20.dll2、分析json:{"code":0,"msg":"ok","data":["d1","d2","d3"]} ,这里解析成如下实体类: public class Roo原创 2018-09-25 16:41:42 · 209 阅读 · 0 评论 -
VS2017建立MVC+NetCore2接入现有数据库
1、 新建项目“eco”,选择“web应用程序(模型视图控制器)”,身份验证为:不进行身份验证。2、 在程序包管理控制台执行命令:Scaffold-DbContext "Data Source=127.0.0.1;Initial Catalog=eco;Persist Security Info=True;User ID=sa;Password=abc123456" Microsof...原创 2018-06-09 09:49:32 · 2022 阅读 · 0 评论 -
C#关于DateTime得到的当前时间的格式和用法
DateTime.Now.ToShortTimeString()DateTime dt = DateTime.Now;dt.ToString();//2005-11-5 13:21:25dt.ToFileTime().ToString();//127756416859912816dt.ToFileTimeUtc().ToString();//127756704859912816...转载 2019-03-07 15:19:00 · 2133 阅读 · 0 评论 -
Html.CheckBox 入门
@Html.CheckBox("name", item.Checked, new { value = item.Id ,@class="col"})原创 2019-06-17 15:41:51 · 2061 阅读 · 0 评论 -
修改了claimsIdentity的值,添加ValidateAntiForgeryToken标签后,无法访问controller,返回400
原因是页面修改了claimsIdentity的值,但是服务器里面还是原来的值,必须重新 HttpContext.SignInAsync一次才能使claimsIdentity服务器端跟客户端一致。原创 2019-06-19 15:18:00 · 1283 阅读 · 1 评论 -
C#线程池、多线程操作、连接ssh、发送ssh命令
1、练笔:using Tamir.SharpSsh;//ssh库private void button1_Click(object sender, EventArgs e) { //方法一:普通线程 //System.Threading.Thread t = new System.Threading.Thread(new Sy转载 2018-04-17 19:14:42 · 1582 阅读 · 0 评论 -
GDI+屏幕截图(directx、dxgi)
GDI+ 、directx、dxgi => 我认为这就是一个东西,因为运行起来,硬件消耗特别低,直接代码: private void button1_Click(object sender, EventArgs e) { System.Threading.Thread thread = new Syst...原创 2019-03-26 23:59:05 · 4319 阅读 · 1 评论