C# WPF 实现读取文件夹中的PDF并显示其页数

文章目录

      • 技术选型
      • 第一步:创建项目并安装依赖库
      • 第二步:定义数据模型 (Model)
      • 第三步:创建视图模型 (ViewModel)
      • 第四步:设计用户界面 (View)
      • 总结与解释
      • 后记
        • 关于转换器的错误

工作中需要整理一些PDF格式文件,程序员的存在就是为了让大家可以“更高效地工作”,而AI的出现就可以让程序更“高效地工作”,于是求助于很长(我指上下文)的Gemini,它帮助了我快速搭建项目,但也给我留下了坑(见本文“后记”部分),于是我把这个开发过程记录了下来。

技术选型

  • UI框架: WPF (.NET 6/7/8 或 .NET Framework 4.7.2+) - 用于构建现代化的Windows桌面应用。
  • PDF处理: iText (替代了旧版的 iTextSharp 及 iText7) - 一个强大且流行的开源PDF处理库。
  • Excel导出: NPOI - 一个开源的.NET库,可以读写Office文档,无需安装Microsoft Office。
  • 设计模式: MVVM - 使UI和业务逻辑分离,提高代码的可测试性和复用性。

第一步:创建项目并安装依赖库

  1. 打开 Visual Studio,创建一个新的 WPF 应用程序 项目(本文为.net 8.0项目)。
    项目类型

  2. 通过 NuGet 包管理器安装以下必要的库。在“解决方案资源管理器”中右键点击你的项目,选择“管理NuGet程序包”,然后搜索并安装:

    • iText
    • NPOI
    • Microsoft.WindowsAPICodePack-Shell (为了一个更好看的文件夹选择对话框)
      主要NuGet包

第二步:定义数据模型 (Model)

这是我们用来存储每个PDF文件信息的类。

PdfFileInfo.cs

namespace PdfFileScanner
{public class PdfFileInfo{public string FileName { get; set; } = string.Empty;public int PageCount { get; set; }public string FileSize { get; set; } = string.Empty;}
}

第三步:创建视图模型 (ViewModel)

ViewModel 是连接视图和模型的桥梁,包含了所有的业务逻辑和UI状态,在这里,我按照AI的提示创建了MainViewModel类。

MainViewModel.cs

using iText.Kernel.Pdf;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using Microsoft.Win32;
using Microsoft.WindowsAPICodePack.Dialogs; // For modern folder browsernamespace PdfFileScanner
{public class MainViewModel : INotifyPropertyChanged{// INotifyPropertyChanged 实现,用于通知UI属性已更改public event PropertyChangedEventHandler? PropertyChanged;protected virtual void OnPropertyChanged(string propertyName){PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));}// 存储PDF文件信息的集合,ObservableCollection能自动通知UI更新public ObservableCollection<PdfFileInfo> PdfFiles { get; } = new ObservableCollection<PdfFileInfo>();private string _statusText = "请选择一个文件夹...";public string StatusText{get => _statusText;set { _statusText = value; OnPropertyChanged(nameof(StatusText)); }}private double _progressValue;public double ProgressValue{get => _progressValue;set { _progressValue = value; OnPropertyChanged(nameof(ProgressValue)); }}private bool _isBusy;public bool IsBusy{get => _isBusy;set{_isBusy = value;OnPropertyChanged(nameof(IsBusy));// 当IsBusy状态改变时,通知命令重新评估其能否执行((RelayCommand)SelectFolderCommand).RaiseCanExecuteChanged();((RelayCommand)ExportToExcelCommand).RaiseCanExecuteChanged();}}// 命令绑定public ICommand SelectFolderCommand { get; }public ICommand ExportToExcelCommand { get; }public MainViewModel(){SelectFolderCommand = new RelayCommand(async () => await ProcessFolderAsync(), () => !IsBusy);ExportToExcelCommand = new RelayCommand(ExportToExcel, () => PdfFiles.Count > 0 && !IsBusy);}private async Task ProcessFolderAsync(){// 使用现代化的文件夹选择对话框var dialog = new CommonOpenFileDialog{IsFolderPicker = true,Title = "请选择包含PDF文件的文件夹"};if (dialog.ShowDialog() == CommonFileDialogResult.Ok){string selectedPath = dialog.FileName;IsBusy = true;StatusText = "正在准备处理...";PdfFiles.Clear();ProgressValue = 0;await Task.Run(() => // 在后台线程执行耗时操作,避免UI卡死{var files = Directory.GetFiles(selectedPath, "*.pdf");int processedCount = 0;foreach (var file in files){processedCount++;var progressPercentage = (double)processedCount / files.Length * 100;// 更新UI元素必须在UI线程上执行Application.Current.Dispatcher.Invoke(() =>{StatusText = $"正在处理: {Path.GetFileName(file)} ({processedCount}/{files.Length})";ProgressValue = progressPercentage;});try{// 获取文件信息var fileInfo = new FileInfo(file);int pageCount = 0;// 使用 iText7 读取PDF页数using (var pdfReader = new PdfReader(file)){using (var pdfDoc = new PdfDocument(pdfReader)){pageCount = pdfDoc.GetNumberOfPages();}}// 创建模型对象并添加到集合中var pdfData = new PdfFileInfo{FileName = fileInfo.Name,PageCount = pageCount,FileSize = $"{fileInfo.Length / 1024.0:F2} KB" // 格式化文件大小};Application.Current.Dispatcher.Invoke(() => PdfFiles.Add(pdfData));}catch (System.Exception ex){// 如果某个PDF文件损坏,记录错误并继续Application.Current.Dispatcher.Invoke(() =>{StatusText = $"处理文件 {Path.GetFileName(file)} 时出错: {ex.Message}";});}}});StatusText = $"处理完成!共找到 {PdfFiles.Count} 个PDF文件。";IsBusy = false;}}private void ExportToExcel(){var saveFileDialog = new SaveFileDialog{Filter = "Excel 工作簿 (*.xlsx)|*.xlsx",FileName = $"PDF文件列表_{System.DateTime.Now:yyyyMMddHHmmss}.xlsx"};if (saveFileDialog.ShowDialog() == true){try{// 使用 NPOI 创建 ExcelIWorkbook workbook = new XSSFWorkbook();ISheet sheet = workbook.CreateSheet("PDF文件信息");// 创建表头IRow headerRow = sheet.CreateRow(0);headerRow.CreateCell(0).SetCellValue("文件名");headerRow.CreateCell(1).SetCellValue("页数");headerRow.CreateCell(2).SetCellValue("文件大小 (KB)");// 填充数据for (int i = 0; i < PdfFiles.Count; i++){IRow dataRow = sheet.CreateRow(i + 1);dataRow.CreateCell(0).SetCellValue(PdfFiles[i].FileName);dataRow.CreateCell(1).SetCellValue(PdfFiles[i].PageCount);dataRow.CreateCell(2).SetCellValue(PdfFiles[i].FileSize);}// 自动调整列宽sheet.AutoSizeColumn(0);sheet.AutoSizeColumn(1);sheet.AutoSizeColumn(2);// 写入文件using (var fs = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write)){workbook.Write(fs);}MessageBox.Show("成功导出到Excel!", "导出成功", MessageBoxButton.OK, MessageBoxImage.Information);}catch (System.Exception ex){MessageBox.Show($"导出失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);}}}}// 一个简单的ICommand实现public class RelayCommand : ICommand{private readonly System.Action _execute;private readonly System.Func<bool>? _canExecute;public event System.EventHandler? CanExecuteChanged{add { CommandManager.RequerySuggested += value; }remove { CommandManager.RequerySuggested -= value; }}public RelayCommand(System.Action execute, System.Func<bool>? canExecute = null){_execute = execute;_canExecute = canExecute;}public bool CanExecute(object? parameter) => _canExecute == null || _canExecute();public void Execute(object? parameter) => _execute();public void RaiseCanExecuteChanged() => CommandManager.InvalidateRequerySuggested();}
}

第四步:设计用户界面 (View)

这是 MainWindow.xaml 文件,定义了程序窗口的布局和控件,并将它们绑定到 ViewModel。

MainWindow.xaml

<Window x:Class="PdfFileScanner.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:PdfFileScanner"mc:Ignorable="d"Title="PDF文件扫描器" Height="600" Width="800" MinHeight="400" MinWidth="600"><!-- 设置窗口的数据上下文为ViewModel --><Window.DataContext><local:MainViewModel/></Window.DataContext><Grid Margin="10"><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><!-- 顶部操作栏 --><StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,10"><Button Content="选择文件夹" Command="{Binding SelectFolderCommand}" Padding="15,5" FontSize="14" IsEnabled="{Binding !IsBusy}"/><Button Content="导出到Excel" Command="{Binding ExportToExcelCommand}" Margin="10,0,0,0" Padding="15,5" FontSize="14" IsEnabled="{Binding !IsBusy}"/></StackPanel><!-- 文件列表 --><DataGrid Grid.Row="1" ItemsSource="{Binding PdfFiles}" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="True" FontSize="14"><DataGrid.Columns><DataGridTextColumn Header="文件名" Binding="{Binding FileName}" Width="*"/><DataGridTextColumn Header="页数" Binding="{Binding PageCount}" Width="Auto"/><DataGridTextColumn Header="文件大小" Binding="{Binding FileSize}" Width="Auto"/></DataGrid.Columns></DataGrid><!-- 底部状态栏和进度条 --><Grid Grid.Row="2" Margin="0,10,0,0"><Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="200"/></Grid.ColumnDefinitions><TextBlock Grid.Column="0" Text="{Binding StatusText}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"/><ProgressBar Grid.Column="1" Value="{Binding ProgressValue}" Maximum="100" Height="20"Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"/></Grid></Grid>
</Window>

MainWindow.xaml.cs (代码隐藏文件)
这里我们只需要确保 DataContext 被正确设置。上面的XAML已经通过 <local:MainViewModel/> 标签完成了这一步,所以代码隐藏文件非常干净。

using System.Windows;namespace PdfFileScanner
{public partial class MainWindow : Window{public MainWindow(){InitializeComponent();// DataContext 在 XAML 中设置,这里无需代码}}
}

总结与解释

  1. 文件夹选择: 点击“选择文件夹”按钮,会触发 SelectFolderCommand。我们使用了 Microsoft.WindowsAPICodePack-Shell 库,它提供了一个比默认的 FolderBrowserDialog 更现代、更友好的对话框。
  2. 后台处理与进度更新:
    • 核心的PDF文件处理逻辑被包裹在 Task.Run() 中,这会将其放到一个后台线程上执行,防止UI线程(负责渲染窗口和响应用户操作的线程)被阻塞而导致程序“未响应”。
    • 在后台线程中,我们不能直接修改UI控件(如 ProgressBarTextBlock)或绑定到UI的集合(如 ObservableCollection)。因此,我们使用 Application.Current.Dispatcher.Invoke() 将这些更新操作“派发”回UI线程执行,这是WPF中进行跨线程UI更新的标准做法。
    • IsBusy 属性用来控制UI状态。当 IsBusytrue 时,按钮会被禁用,进度条会显示。
  3. 信息提取:
    • 文件名和大小: 使用 System.IO.FileInfo 类可以轻松获取。
    • PDF页数: 使用 iText 7 库。我们通过 PdfReaderPdfDocument 对象打开PDF文件,然后调用 GetNumberOfPages() 方法。using 语句确保文件流被正确关闭和释放。
  4. 列表展示:
    • WPF的 DataGrid 控件的 ItemsSource 属性被绑定到 ViewModel 中的 ObservableCollection<PdfFileInfo> 集合。
    • ObservableCollection 的美妙之处在于,每当你向其中 AddRemove 一个项时,它会自动通知绑定的 DataGrid 更新,无需手动刷新。
  5. Excel导出:
    • 点击“导出到Excel”按钮会触发 ExportToExcelCommand
    • 该命令首先会弹出一个标准的“文件保存”对话框,让用户选择保存位置和文件名。
    • 然后,它使用 NPOI 库在内存中创建一个Excel工作簿 (XSSFWorkbook 对应 .xlsx格式),创建工作表、表头行,然后遍历 PdfFiles 集合,将每条数据写入新的一行。
    • 最后,将内存中的工作簿写入到用户选择的文件流中。

这个方案完整地实现了你要求的所有功能,并且采用了现代C#和WPF的最佳实践,代码结构清晰,易于扩展和维护。

后记

关于转换器的错误

Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}" 改代码因没有转换器Converter而出错,故需自定义一个转换器:

添加转换器类BooleanToVisibilityConverter

using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;public class BooleanToVisibilityConverter : IValueConverter
{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){if (value is bool booleanValue){if (booleanValue){return Visibility.Visible;}else{// Default to Collapsed, or Hidden based on 'parameter' or another propertyreturn Visibility.Collapsed;}}return Visibility.Visible; // Default if not a boolean}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotImplementedException(); // Usually not needed for Visibility conversion}
}

然后在 MainWindow.xaml 中注册这个转换器:

    <!-- 在这里添加资源定义 --><Window.Resources><BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/></Window.Resources>

修改后的MainWindow.xaml文件如下:

<Window x:Class="PdfFileScanner.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:PdfFileScanner"mc:Ignorable="d"Title="PDF文件扫描器" Height="600" Width="800" MinHeight="400" MinWidth="600"><!-- 设置窗口的数据上下文为ViewModel --><Window.DataContext><local:MainViewModel/></Window.DataContext><!-- 在这里添加资源定义 --><Window.Resources><BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/></Window.Resources><Grid Margin="10"><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><!-- 顶部操作栏 --><StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,10"><Button Content="选择文件夹" Command="{Binding SelectFolderCommand}" Padding="15,5" FontSize="14" IsEnabled="{Binding !IsBusy}"/><Button Content="导出到Excel" Command="{Binding ExportToExcelCommand}" Margin="10,0,0,0" Padding="15,5" FontSize="14" IsEnabled="{Binding !IsBusy}"/></StackPanel><!-- 文件列表 --><DataGrid Grid.Row="1" ItemsSource="{Binding PdfFiles}" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="True" FontSize="14"><DataGrid.Columns><DataGridTextColumn Header="文件名" Binding="{Binding FileName}" Width="*"/><DataGridTextColumn Header="页数" Binding="{Binding PageCount}" Width="Auto"/><DataGridTextColumn Header="文件大小" Binding="{Binding FileSize}" Width="Auto"/></DataGrid.Columns></DataGrid><!-- 底部状态栏和进度条 --><Grid Grid.Row="2" Margin="0,10,0,0"><Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="200"/></Grid.ColumnDefinitions><TextBlock Grid.Column="0" Text="{Binding StatusText}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis"/><ProgressBar Grid.Column="1" Value="{Binding ProgressValue}" Maximum="100" Height="20"Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibilityConverter}}"/></Grid></Grid>
</Window>

问题解决!

运行效果如下:

软件界面

文件识别

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/pingmian/91061.shtml
繁体地址,请注明出处:http://hk.pswp.cn/pingmian/91061.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

设计模式(五)创建型:原型模式详解

设计模式&#xff08;五&#xff09;创建型&#xff1a;原型模式详解原型模式&#xff08;Prototype Pattern&#xff09;是 GoF 23 种设计模式中的创建型模式之一&#xff0c;其核心价值在于通过复制现有对象来创建新对象&#xff0c;而不是通过 new 关键字调用构造函数。它特…

K8S 八 数据存储-高级存储PV PVC 生命周期;配置存储ConfigMap Secret

目录数据存储 Volume8.1 基本存储8.1.1 EmptyDir8.1.2 HostPath 挂载目录8.1.3 NFSnfs的服务8.2 高级存储8.2.1 PV和PVC8.2.2 PV 持久化卷申请8.2.3 PVC 资源申请PVC的配置参数8.2.4 生命周期配置存储8.3.1 ConfigMap8.3.2 Secret数据存储 Volume Kubernetes的Volume支持多种类…

Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型实现轮船检测识别(C#代码UI界面版)

Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型实现轮船检测识别&#xff08;C#代码UI界面版&#xff09;工业相机使用YoloV8模型实现轮船检测识别工业相机通过YoloV8模型实现轮船检测识别的技术背景在相机SDK中获取图像转换图像的代码分析工业相机图像转换Bitmap图像格…

自习室预约小程序的设计与实现

自习室预约小程序的设计与实现现代学习环境对高效、便捷的预约系统需求日益增长。自习室预约小程序结合前沿技术栈&#xff0c;提供流畅的用户体验和强大的后台管理功能&#xff0c;满足学生、职场人士等群体的自习需求。技术架构与核心功能Vue.js 构建动态前端界面 采用 Vue.j…

Docker 实战大纲

文章目录Docker 实战 – Mysql &#xff08;敬请期待……&#xff09;

从一个“诡异“的C++程序理解状态机、防抖与系统交互

引言 在编程世界中&#xff0c;有时一个看似简单的代码片段可能隐藏着令人惊讶的复杂性。本文将从一个"故意设计"的C程序出发&#xff0c;深入探讨其背后涉及的状态机模式、防抖机制以及操作系统与控制台的交互原理。通过这个案例&#xff0c;我们不仅能理解这些核心…

NAS-Bench-101: Towards Reproducible Neural Architecture Search

概述这篇题为"NAS-Bench-101: Towards Reproducible Neural Architecture Search"的论文由Chris Ying等人合作完成&#xff0c;旨在解决神经网络架构搜索(NAS)领域面临的重大挑战&#xff1a;计算资源需求高和实验难以复现的问题。论文提出了NAS-Bench-101&#xff0…

SpringBoot整合Fastexcel/EasyExcel导出Excel导出多个图片

整个工具的代码都在Gitee或者Github地址内 gitee&#xff1a;solomon-parent: 这个项目主要是总结了工作上遇到的问题以及学习一些框架用于整合例如:rabbitMq、reids、Mqtt、S3协议的文件服务器、mongodb、xxl-job、powerjob还有用Docker compose部署各类中间组件。如果大家有…

网络原理--HTTPHTTPS

目录 一、HTTP 1.1 HTTP是什么 1.2 HTTP协议的工作过程 1.3 HTTP协议格式 1.3.1 抓包工具的使用 1.3.2 抓包结果 1.4 HTTP请求 1.4.1 URL 1.4.2 认识“方法” (method) 1.4.3 认识请求“报头”(header) 1.4.4 认识请求“正文”(body) 1.5 HTTP 响应详解 1.5.1 HTTP…

『 C++ 入门到放弃 』- 哈希表

一、哈希的概念 哈希&#xff0c;也称「 散列 」是一种用来进行高效查找的数据结构&#xff0c;查找的时间复杂度平均为O(1)&#xff0c;其本质就是依赖哈希函数这个算法来将 key 和该 key 存储位置建立一个映射关系。 而因为是有着映射关系&#xff0c;所以哈希的事件复杂度为…

零售收银系统开源代码全解析:连锁门店一体化解决方案(含POS+进销存+商城)

过去10年&#xff0c;收银系统技术经历了从单机版到云服务、从单纯结算到全渠道整合的快速演进。面对连锁多门店、AI称重、智能分账、跨店库存同步等新需求&#xff0c;很多企业的现有传统saas系统已显乏力。本文将梳理收银系统关键技术指标&#xff0c;助您在系统升级时做出明…

能源高效利用如何实现?楼宇自控系统智能化监管建筑设备

随着全球能源危机日益严峻和“双碳”目标的持续推进&#xff0c;建筑领域作为能耗大户&#xff08;约占社会总能耗的40%&#xff09;&#xff0c;其节能潜力备受关注。楼宇自控系统&#xff08;Building Automation System&#xff0c;简称BAS&#xff09;作为建筑智能化的核心…

校园二手交易小程序的设计与实现

文章目录前言详细视频演示具体实现截图后端框架SpringBoot微信小程序持久层框架MyBaits成功系统案例&#xff1a;参考代码数据库源码获取前言 博主介绍:CSDN特邀作者、985高校计算机专业毕业、现任某互联网大厂高级全栈开发工程师、Gitee/掘金/华为云/阿里云/GitHub等平台持续…

Redis(二):Redis高级特性和应用(慢查询、Pipeline、事务)

Redis的慢查询 许多存储系统&#xff08;例如 MySQL)提供慢查询日志帮助开发和运维人员定位系统存在的慢操作。所谓慢查询日志就是系统在命令执行前后计算每条命令的执行时间&#xff0c;当超过预设阀值,就将这条命令的相关信息&#xff08;例如:发生时间&#xff0c;耗时&…

如何为你的WordPress网站选择合适的安全插件

在管理WordPress网站时&#xff0c;安全因素至关重要。由于WordPress的广泛使用&#xff0c;它也成为了黑客攻击的首要目标。为了避免潜在的安全风险&#xff0c;选择合适的安全插件至关重要。而Wordfence和iThemes&#xff0c;作为两款颇具人气的WordPress安全插件&#xff0c…

我们使用Rust开发的AI知识库应用

这段时间陆陆续续的开发了2个AI知识库应用&#xff0c;一个面向企业&#xff0c;一个面向C端用户。 飞树智库&#xff1a;一个安全高效的面向 企业的知识库平台&#xff08;https://fskb.coderbox.cn/&#xff09;。 小飞树&#xff1a;一个专注于个人知识管理的AI应用&#…

自动化测试实战篇

目录 1. 自动化实施步骤 1.1 编写web测试用例 1.2 自动化测试脚本开发 1.3 将自动化测试补充至测试报告 1. 自动化实施步骤 1.1 编写web测试用例 1.2 自动化测试脚本开发 TestDevelopment: 测试用例 - Gitee.comhttps://gitee.com/Axurea/test-development/tree/master/2…

idea 服务器Debug端口启动设置

一&#xff1a;在阿里云服务器安全组已经设置了端口授权对象&#xff1a;正确命令&#xff1a;nohup java -Xdebug -Xrunjdwp:transportdt_socket,servery,suspendn,address9998 -jar -Duser.timezoneGMT08 -Xms256m -Xmx256m /opt/projects/*/*/*-starter-1.0-SNAPSHOT.jar -…

大模型量化004

Bert P-tuning BertPET、BertP-Tuning Chain of Thought Few shot Cot Auto-COT 解决手动编写高质量CoT示例麻烦耗时的问题 Auto COT 自动思维链生成器 1.业务场景&#xff1a; 每天收到很多反馈&#xff0c;之前需要人工整理&#xff0c;找到重点&#xff0c;做判断那些需要立…

C#(基本语法)

数据类型C#是一种强类型语言&#xff0c;变量必须声明类型。基本数据类型包括整型&#xff08;int、long&#xff09;、浮点型&#xff08;float、double&#xff09;、布尔型&#xff08;bool&#xff09;、字符型&#xff08;char&#xff09;和字符串型&#xff08;string&a…