我无法删除此文件,为什么? [英] i can't delete this file, why?
问题描述
嗨
我正在使用VB.NET 203
我正在研究从照片中读取元数据的应用程序
数码相机。
我使用此代码:
Dim imageX =新位图(PhotoFullFileNameX )
Dim propItems As PropertyItem()= imageX.PropertyItems
....
....
....
它运作良好
但在我阅读信息后我需要删除此文件:
file.Delete(PhotoFullFileNameX)
但我有这个错误:
类型''系统的未处理异常。 IO.IOException''发生在
mscorlib.dll
附加信息:该进程无法访问该文件
" filename.jpg"
因为它正在被另一个进程使用。
这意味着该文件仍处于打开状态(位图功能)
我必须做些什么来关闭这个骗局提示???
-
最好的问候
Tark M. Siala
开发经理
国际计算机中心(ICC.Networking)
Messenger: ta ** *****@hotmail.com
网页: http://www.icc-libya.com
========================= =============
Tark Siala schrieb:hi
我正在研究VB.NET 203
我正致力于从照片中读取元数据的应用程序从数码相机中获取它。
我使用这段代码:
Dim imageX =新位图(PhotoFullFileNameX)
Dim propItems As PropertyItem()= imageX.PropertyItems
....
....
....
它工作得很好
但在我读完信息之后我需要删除这个文件:
file.Delete(PhotoFullFileNameX)
但是我有这个错误:
类型''System.IO.IOException''的未处理异常发生在
mscorlib.dll
附加信息:该进程无法访问文件
filename.jpg
因为它正被另一个进程使用。
>这意味着文件仍处于打开状态(位图功能)
我必须做什么来关闭此连接???
可能你之前没有处理过imageX删除文件。如果你想要删除它并且仍然在内存中保留位图,你必须将imageX复制到
新位图并在删除文件之前配置imageX。
要复制位图,您只需编写:
dim bmpToKeep as bitmap
bmpToKeep = new bitmap(imageX)
Armin
thx
但是我如何处理imageX?
-
================================== ====
" Armin Zingler" < AZ ******* @ freenet.de>写在消息
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...Tark Siala schrieb:嗨
我正在研究VB.NET 203
我正致力于从照片中读取元数据的应用程序从<数码相机。
我使用这段代码:
Dim imageX =新位图(PhotoFullFileNameX)
Dim propItems As PropertyItem()= imageX .PropertyItems
....
....
....
它工作得很好
但在我读完信息后需要删除此文件:
file.Delete(PhotoFullFileNameX)
但我有这个错误:
类型''系统未处理的异常.IO.IOException''发生在
mscorlib.dll
附加信息:该进程无法访问文件
filename.jpg
因为它正被另一个进程使用。
这就是意思e文件仍处于打开状态(位图功能)
我必须做什么来关闭此连接???
可能你在删除文件之前没有处理imageX。如果你想要删除它并仍然在内存中保留一个位图,你必须将imageX复制到一个新的位图并在删除文件之前配置imageX。
复制位图,你可以简单地写一下:
dim bmpToKeep as bitmap
bmpToKeep = new bitmap(imageX)
Armin
On Thu,2005年7月14日14:47:07 +0200,Tark Siala
< ta ******* @ icc-libya。 COM>写道:
昏暗的imageX =新的位图(PhotoFullFileNameX)
Dim propItems作为PropertyItem()= imageX.PropertyItems
....
.. ..
....
尝试使用流打开图像,您可以在关闭之前关闭图像
删除:
Dim file As New IO.FileStream(" c:\ temp\image.gif",
IO.FileMode.Open)
昏暗图像As Image = image.FromStream(file)
file.Close()
IO.File.Delete(" c:\ temp \ image.gif")
希望这会有所帮助
Tom
hi
i''m working on VB.NET 203
and i''m working on application that read Metadata from Photo Take it from
Digital Camera.
i''m use this code:
Dim imageX = New Bitmap(PhotoFullFileNameX)
Dim propItems As PropertyItem() = imageX.PropertyItems
....
....
....
it''s working good
but after i read information i need delete this file with:
file.Delete(PhotoFullFileNameX)
but i have this error:
An unhandled exception of type ''System.IO.IOException'' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"filename.jpg"
because it is being used by another process.
that''s mean the file still under open with (bitmap function)
what i must do to close this connection???
--
Best Regards
Tark M. Siala
Development Manager
INTERNATIONAL COMPUTER CENTER (ICC.Networking)
Messenger: ta*******@hotmail.com
Web Page: http://www.icc-libya.com
======================================
Tark Siala schrieb:hi
i''m working on VB.NET 203
and i''m working on application that read Metadata from Photo Take it from
Digital Camera.
i''m use this code:
Dim imageX = New Bitmap(PhotoFullFileNameX)
Dim propItems As PropertyItem() = imageX.PropertyItems
....
....
....
it''s working good
but after i read information i need delete this file with:
file.Delete(PhotoFullFileNameX)
but i have this error:
An unhandled exception of type ''System.IO.IOException'' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"filename.jpg"
because it is being used by another process.
that''s mean the file still under open with (bitmap function)
what i must do to close this connection???
Probably you did not dispose imageX before deleting the file. If you want to
delete it and still keep a bitmap in memory, you have to copy imageX to a
new bitmap and dispose imageX before deleting the file.
To copy the bitmap, you can simply write:
dim bmpToKeep as bitmap
bmpToKeep = new bitmap(imageX)
Armin
thx
but how i can dispose imageX ?
--
======================================
"Armin Zingler" <az*******@freenet.de> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...Tark Siala schrieb:hi
i''m working on VB.NET 203
and i''m working on application that read Metadata from Photo Take it from
Digital Camera.
i''m use this code:
Dim imageX = New Bitmap(PhotoFullFileNameX)
Dim propItems As PropertyItem() = imageX.PropertyItems
....
....
....
it''s working good
but after i read information i need delete this file with:
file.Delete(PhotoFullFileNameX)
but i have this error:
An unhandled exception of type ''System.IO.IOException'' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"filename.jpg"
because it is being used by another process.
that''s mean the file still under open with (bitmap function)
what i must do to close this connection???
Probably you did not dispose imageX before deleting the file. If you want
to delete it and still keep a bitmap in memory, you have to copy imageX to
a new bitmap and dispose imageX before deleting the file.
To copy the bitmap, you can simply write:
dim bmpToKeep as bitmap
bmpToKeep = new bitmap(imageX)
Armin
On Thu, 14 Jul 2005 14:47:07 +0200, "Tark Siala"
<ta*******@icc-libya.com> wrote:
Dim imageX = New Bitmap(PhotoFullFileNameX)
Dim propItems As PropertyItem() = imageX.PropertyItems
....
....
....
Try opening the image using a stream, which you can close before
deleting:
Dim file As New IO.FileStream("c:\temp\image.gif",
IO.FileMode.Open)
Dim image As Image = image.FromStream(file)
file.Close()
IO.File.Delete("c:\temp\image.gif")
Hope this helps
Tom
这篇关于我无法删除此文件,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!