powershell - Visual Studio PowerShell 使列表框拖放文件可用
问题描述
我listbox
在我的 Windows 窗体中设置了一个可以将文件拖放到其中的设置,我想要实现的第一件事是只显示文件名而不是路径,请参见下面的代码块。
$handler = {
$_.Data.GetFileDropList() | % {
$listbox1.Items.Add($_)
}
}
$listbox1.AllowDrop = $true
$listbox1.Add_DragEnter({$_.Effect = [Windows.Forms.DragDropEffects]::Copy})
$listbox1.Add_DragDrop($handler)
PowerShell
第二个目标是能够.pdf
在listbox1
.
我的.pdf
组合脚本如下
$button2_Click = {
$pdftk = "C:\Program Files (x86)\PDFtk Server\bin\pdftk.exe"
$inputFolder = "E:\SIGNEDNOTES"
$outputFolder = "E:\out\"
$IntactScan = Get-ChildItem $inputFolder -File | Measure-Object | % {$_.Count}
If ($IntactScan -gt $maxItems) {
Get-Childitem $inputFolder -filter *.pdf -Recurse
pdftk "E:\SIGNEDNOTES\*.pdf" cat Output $outputFolder\Rename.pdf
Move-Item "E:\SIGNEDNOTES\*.pdf" "E:\Backup\"
}
else {
exit
}
}
基本上我希望用户能够将 2 x pdf 文件拖入listBox1
并按下组合按钮并将组合输出.pdf
到第二个listBox2
解决方案
关于我的第一个问题,这正在进行中,但在 2 中不太重要的一个
我通过下面的代码解决了另一个问题(组合来自 listBox 的 2 个 pdf)
$pdftk = "C:\Program Files (x86)\PDFtk Server\bin\pdftk.exe"
$inputFolder = $listbox1.Items
$outputFolder = "E:\out"
$CountyCount = Get-ChildItem $inputFolder -File | Measure-Object | % {$_.Count}
If ($CountyCount -gt $maxItems) {
Get-Childitem $inputFolder -filter *.pdf -Recurse
pdftk $listbox1.Items cat Output $outputFolder\Combine.pdf
$listbox1.Items.Clear()
#Move-Item "E:\SIGNEDNOTES\*.pdf" "E:\Backup\"
}
else {
exit
}
}```
thank you for your help
推荐阅读
- r - 为同一 ggplot 中使用的不同 data.frames 手动添加附加图例
- firebase - Flutter Fire 中的 userChanges 流不会流式传输配置文件更改
- r - 计算平均值的函数
- flutter - 如何在 ListView 项目中展开列?
- python - Pandas 布尔检查意外返回 True 而不是 False
- python - 如何从字典中的随机列表中选择随机项目
- c++ - 为什么windbg 不能在内核模式转储中显示我的用户模式调用堆栈?
- flutter - 提供 AnimatedSwitcher Flutter
- python - Pandas 将所有列转换为数据条目并为其当前值创建新列
- android - 从 mikepenz 材料抽屉中的数组中获取配置文件项目