473,608 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i can't delete this file, why?

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(PhotoFul lFileNameX)
Dim propItems As PropertyItem() = imageX.Property Items
....
....
....

it's working good
but after i read information i need delete this file with:

file.Delete(Pho toFullFileNameX )

but i have this error:

An unhandled exception of type 'System.IO.IOEx ception' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"filename.j pg"
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*******@hotma il.com
Web Page: http://www.icc-libya.com
=============== =============== ========
Nov 21 '05 #1
11 5564
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(PhotoFul lFileNameX)
Dim propItems As PropertyItem() = imageX.Property Items
....
....
....

it's working good
but after i read information i need delete this file with:

file.Delete(Pho toFullFileNameX )

but i have this error:

An unhandled exception of type 'System.IO.IOEx ception' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"filename.j pg"
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
Nov 21 '05 #2
thx
but how i can dispose imageX ?

--
=============== =============== ========
"Armin Zingler" <az*******@free net.de> wrote in message
news:%2******** ********@tk2msf tngp13.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(PhotoFul lFileNameX)
Dim propItems As PropertyItem() = imageX.Property Items
....
....
....

it's working good
but after i read information i need delete this file with:

file.Delete(Pho toFullFileNameX )

but i have this error:

An unhandled exception of type 'System.IO.IOEx ception' occurred in
mscorlib.dll
Additional information: The process cannot access the file
"filename.j pg"
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

Nov 21 '05 #3
On Thu, 14 Jul 2005 14:47:07 +0200, "Tark Siala"
<ta*******@ic c-libya.com> wrote:
Dim imageX = New Bitmap(PhotoFul lFileNameX)
Dim propItems As PropertyItem() = imageX.Property Items
....
....
....


Try opening the image using a stream, which you can close before
deleting:

Dim file As New IO.FileStream(" c:\temp\image.g if",
IO.FileMode.Ope n)
Dim image As Image = image.FromStrea m(file)
file.Close()
IO.File.Delete( "c:\temp\image. gif")

Hope this helps

Tom
Nov 21 '05 #4
Tark Siala schrieb:
thx
but how i can dispose imageX ?


imageX.Dispose
Armin
Nov 21 '05 #5
imageX is Bitmap Object
and when i type imageX.dispose system can't know this method
"Armin Zingler" <az*******@free net.de> wrote in message
news:eC******** ******@TK2MSFTN GP10.phx.gbl...
Tark Siala schrieb:
thx
but how i can dispose imageX ?


imageX.Dispose
Armin

Nov 21 '05 #6
you cant do that
because i use Bitmap Object to get Metadata info
when i use Image Object i can't read Metadata info

--
Best Regards

Tark M. Siala
=============== =============== ========
"Tom John" <forums[at]redfrog[dot]com> wrote in message
news:hs******** *************** *********@4ax.c om...
On Thu, 14 Jul 2005 14:47:07 +0200, "Tark Siala"
<ta*******@ic c-libya.com> wrote:
Dim imageX = New Bitmap(PhotoFul lFileNameX)
Dim propItems As PropertyItem() = imageX.Property Items
....
....
....


Try opening the image using a stream, which you can close before
deleting:

Dim file As New IO.FileStream(" c:\temp\image.g if",
IO.FileMode.Ope n)
Dim image As Image = image.FromStrea m(file)
file.Close()
IO.File.Delete( "c:\temp\image. gif")

Hope this helps

Tom

Nov 21 '05 #7
Tark Siala schrieb:
imageX is Bitmap Object
and when i type imageX.dispose system can't know this method


I can't reproduce this. Dispose is not an advanced member, so it should be
shown always. Isn't it listed via intellisense or doesn't it compile?
Armin
Nov 21 '05 #8
Bitmap inherits from Image so you should be able to do what you want.

Dim file As New IO.FileStream(" c:\temp\image.g if", IO.FileMode.Ope n)
Dim b As Bitmap = DirectCast(Imag e.FromStream(fi le),Bitmap)
file.Close()
IO.File.Delete( "c:\temp\image. gif")

Nov 21 '05 #9
hi
when i did what you tell, i get the Error Message:

A generic error occurred in GDI+

maby image from file stream not support metadata.
--
Best Regards
=============== =============== ========
"Tom John" <forums[at]redfrog[dot]com> wrote in message
news:hs******** *************** *********@4ax.c om...
On Thu, 14 Jul 2005 14:47:07 +0200, "Tark Siala"
<ta*******@ic c-libya.com> wrote:
Dim imageX = New Bitmap(PhotoFul lFileNameX)
Dim propItems As PropertyItem() = imageX.Property Items
....
....
....


Try opening the image using a stream, which you can close before
deleting:

Dim file As New IO.FileStream(" c:\temp\image.g if",
IO.FileMode.Ope n)
Dim image As Image = image.FromStrea m(file)
file.Close()
IO.File.Delete( "c:\temp\image. gif")

Hope this helps

Tom

Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3199
by: lawrence | last post by:
I've two scripts, one to upload images, another to delete them. The upload script works fine, but the delete script has permissions trouble. How can PHP not have permission to delete an image it itself uploaded? Here is the delete script I'm using right now, and the error messages I got below.
18
9089
by: Dino | last post by:
dear all, i've created an application for a customer where the customer can upload ..csv-files into a specified ftp-directory. on the server, a php-script, triggered by a cronjob, reads all the data, imports it into a mySQL database and deletes the .csv-file after the import. so far, so good. but in some cases the cronjobs starts running when the file is not completely
0
1652
by: Phil... | last post by:
I have a directory with a lot of jpg files. I want to delete the small ones. Small means less than 100 pixels by 100 pixels. I use File.list() to get the list of files. I use ImageIcon(filename) to create an ImageIcon. I use getIconHeight() and getIconWidth(). then I try to delete the file if it meets the "small" test. I tried to use File.delete(), but most of the time this returns "false" and the file is not deleted. If I use...
0
2086
by: SeanR | last post by:
I have a function to copare two files. It will first copy the original file form a different server to a local temp path and then compare that version to a version that has been restored form tape. Once the compare is complete the file that was copied to a temp location needs to be deleted. I am using the method file.copy(sourcePath, tempPath, true) to copy the file and then file.delete(tempPath) to delete the file. On some of the files...
5
5232
by: | last post by:
Hi all, I've been using C++ for quite a while now and I've come to the point where I need to overload new and delete inorder to track memory and probably some profiling stuff too. I know that discussions of new and delete is a pretty damn involved process but I'll try to stick to the main information I'm looking for currently. I've searched around for about the last too weeks and have read up on new and overloading it to some extent but...
12
7986
by: Lucas Tam | last post by:
I have a very simple loop: If (Directory.Exists(tempDirectory)) Then Try Dim Files() As String = Directory.GetFiles(tempDirectory) 'Clear out directory For Each Filename As String In Files File.Delete(Filename) Next Catch ex As Exception
9
8316
by: Paul | last post by:
I'm trying to make get my app to delete all the files in a specified folder and all the files within the folders of the specified folder. e.g. Folder 1 contains three files (File1, File2, File3) and two folders (Subfolder 1, Subfolder 2). .......I need to delete File1, File2, File3. Subfolder 1 contains FileA. .......Need to delete FileA. Subfolder 2 contains FileB, FileC, FileD.
2
4740
by: createdbyx | last post by:
I am trying to make a file sync utillity to sync files between my laptop and my desktop pc. On my desktop machine (xp pro sp2) I have shared my "Visual Studio Projects" folder using windows simple file sharing. And have specified the "Allow network users to change my files." option as well. Then on my laptop (xp home sp2) I have mapped a network drive using windows explorer. So on my laptop I have a Y: drive that points to the "Visual...
2
2748
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include <string>
13
2384
by: darrel | last post by:
When I write scripts for deleting records in databases, I tend to do it in this fashion: - delete link passes ID to a delete.aspx page - delete.aspx page queries db using that ID to retrieve the file information - page displays file information with a 'are you sure you want to delete' confirmation button. - upon clicking said button, I delete the record.
0
8057
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8491
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8470
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8142
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5475
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2472
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1580
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1327
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.