首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >打印后不能在aBarcode中删除VB.NET图像(KeepAutomation)

打印后不能在aBarcode中删除VB.NET图像(KeepAutomation)
EN

Stack Overflow用户
提问于 2017-03-08 09:23:41
回答 1查看 55关注 0票数 0

我正在建立一个标签打印机与代码128条码与KeepAutomation。

在这个过程中,我实际上:

  1. 使用KeepAutomation引用模块将数据编码为条形码 MakeImage() KeepAutomation.Barcode.Bean.BarCode = New KeepAutomation.Barcode.Bean.BarCode barcode.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto barcode.CodeToEncode = Me.txtCatNum.Text barcode.X =2 barcode.Y =0 barcode.LeftMargin =0 barcode.LeftMargin=0 barcode.TopMargin =0 barcode.DisplayText = True barcode.ChecksumEnabled = True barcode.DisplayChecksum = KeepAutomation.Barcode.Orientation.Degree0 barcode.Orientation =KeepAutomation.Barcode.Orientation.Degree0 barcode.BarcodeUnit = 72 = New Font("Arial",26.0F ),( FontStyle.Regular) barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg barcode.generateBarcodeToImageFile(FileToUse)
  2. 从编码的数据创建Jpeg映像(具有静态名称到硬盘上的特定位置)
  3. 将图像放置在PrintDocument中
  4. 打印出来

但是,在再次运行该过程之前,当我尝试删除该文件时,它会告诉我,它不能删除该文件,因为它被应用程序本身使用(如果发布)或vshost32 32-clr2.exe(调试时)。

我试过:

  1. 处理PrintDocument类
  2. 处理、关闭和ReOpening表单本身。

所有这些都帮不了我。

寻找一个好主意(然后为我创建的每个标签创建一个不同的图像)

谢谢,盖伊

EN

回答 1

Stack Overflow用户

发布于 2017-03-08 13:28:19

谢谢朋友们

我用pinkfloydx33的线索找到了我的问题的完美答案

我已经为我正在创建的jpeg创建了一个FileStream,以“只读”的形式打开它,一旦将它放到PrintDocument类上,我就可以很容易地覆盖/删除它。

这是我使用的密码..。

代码语言:javascript
复制
       MakeImage()
    Dim fs As New FileStream(FileToUse, FileMode.Open, FileAccess.Read)
    e.Graphics.DrawImage(Image.FromStream(fs), 20, 5, 150, 80)
    e.Graphics.DrawString("Batch: ___________", BatchFont, Brushes.Black, 0, 97)
    fs.Dispose()

结论,请允许我.

每当您打开一个文件,特别是当您不需要修改它,访问它作为FS和打开作为ReadOnly……

再次感谢。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42667397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档