vb.net保存文件帮忙 60
第一次成功第二次保存时候出问题My.Computer.FileSystem.DeleteFile("C:\ytakqi1.png")'删除指定文件'textbox,lab...
第一次成功第二次保存时候出问题
My.Computer.FileSystem.DeleteFile("C:\ytakqi1.png") '删除指定文件
'textbox,label中的图片转保存图片格式
Dim txtToDraw As Control
txtToDraw = Me.Label13 '保存的控件名称
Dim bit As Bitmap
bit = New Bitmap(txtToDraw.ClientRectangle.Width,
txtToDraw.ClientRectangle.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb)
txtToDraw.DrawToBitmap(bit, txtToDraw.ClientRectangle)
Using g As Graphics = Graphics.FromImage(bit)
g.Clear(Color.Transparent)
Dim p As Point = txtToDraw.PointToClient(Point.Empty)
p.X = -p.X
p.Y = -p.Y
g.CopyFromScreen(p, Point.Empty, txtToDraw.ClientSize)
g.Flush()
End Using
bit.Save("C:\ytakqi1.png") '保存文件的路径
'==================================================’
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
PictureBox3.Image = System.Drawing.Bitmap.FromFile("C:\ytakqi1.png")
End Sub
第二次保存时候出现进程里面已存在 ytakqi.png 怎么解决 展开
My.Computer.FileSystem.DeleteFile("C:\ytakqi1.png") '删除指定文件
'textbox,label中的图片转保存图片格式
Dim txtToDraw As Control
txtToDraw = Me.Label13 '保存的控件名称
Dim bit As Bitmap
bit = New Bitmap(txtToDraw.ClientRectangle.Width,
txtToDraw.ClientRectangle.Height,
System.Drawing.Imaging.PixelFormat.Format32bppArgb)
txtToDraw.DrawToBitmap(bit, txtToDraw.ClientRectangle)
Using g As Graphics = Graphics.FromImage(bit)
g.Clear(Color.Transparent)
Dim p As Point = txtToDraw.PointToClient(Point.Empty)
p.X = -p.X
p.Y = -p.Y
g.CopyFromScreen(p, Point.Empty, txtToDraw.ClientSize)
g.Flush()
End Using
bit.Save("C:\ytakqi1.png") '保存文件的路径
'==================================================’
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
PictureBox3.Image = System.Drawing.Bitmap.FromFile("C:\ytakqi1.png")
End Sub
第二次保存时候出现进程里面已存在 ytakqi.png 怎么解决 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询