473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

can't delete picture....

hello to everybody...

in of directories on my pc i have a list of su-directories, and in each
directory theres an image "picture.ico"...
so then my program is starting to run, i add a new listviewitem to my
listview component then each item represents one of this subfolders, i also
has imagelist, and with adding new item to listview i add image
"picture.ico" to my imagelist...
.... hope my english working well in explaining myself...

-- it works this way:

foreach (System.IO.DirectoryInfo subdir in dir.GetDirectories())
{
imageList.Images.Add ( System.Drawing.Image.FromFile( subdir.FullName +
@"\picture.ico") );
System.Windows.Forms.ListViewItem lvi = new ListViewItem(subdir.Name,
imagelist.Images.Count - 1);
listView.Items.Add(lvi);
}

when time comes i decide to delete one of those sub-directories:

System.Windows.Forms.ListViewItem lvi = listView.SelectedItems[0];
System.IO.DirectoryInfo di = (System.IO.DirectoryInfo) lvi.Tag;
int i = listView.Items.IndexOf(lvi);
listView.Items.Remove(lvi);
System.Drawing.Image Image = imageList.Images[i];
imageList.Images.Remove( Image );
di.Delete(true);

but it falls on last line, saying picture.ico is in use by other program...
why is that?
and that is yours suggestions at all...

thnx...
David...
Nov 16 '05 #1
4 4513
when time comes i decide to delete one of those sub-directories:

System.Windows.Forms.ListViewItem lvi = listView.SelectedItems[0];
System.IO.DirectoryInfo di = (System.IO.DirectoryInfo) lvi.Tag;
int i = listView.Items.IndexOf(lvi);
listView.Items.Remove(lvi);
System.Drawing.Image Image = imageList.Images[i];
imageList.Images.Remove( Image );
di.Delete(true);

but it falls on last line, saying picture.ico is in use by other
program...
why is that?
and that is yours suggestions at all...


Try adding Image.Dispose() between removing the image from the image list
and tryign to delete it.
Nov 16 '05 #2
same exeption :(((
"picture.ico" is used by another program...
Nov 16 '05 #3

"David" <da*******@hotmail.com> wrote in message
news:uz**************@TK2MSFTNGP11.phx.gbl...
same exeption :(((
"picture.ico" is used by another program...

Hmmm, I would guess either your app or an entirelyu different one is still
accessing it. Odd, to say the least.

Perhaps you should load the file via a file stream manually, and then
loading the image from a memory stream instead of allowing the Image class
to do it for you. I *doubt* thats the problem, but its a place to start.
Nov 16 '05 #4
thanx fo replying
but i allreday fixed the problem...
Nov 16 '05 #5

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

Similar topics

2
by: U C | last post by:
Hi, Can i delete files in cdump folder. Whats the basic use of having files in cdump folder. Is there any need to take backup when deleting the same. I am having solaris if we can delet then what...
0
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....
14
by: Timothy Madden | last post by:
Hello I have a linked list of object of a class. I thought it would be nice to have the destructor delete the whole list when I delete just the first element. I don't want to recursivly destroy...
2
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...
21
by: Roman Werpachowski | last post by:
I can't understand this: double * x = new double; const double * p = x; delete p; works. Why am I allowed to delete a const pointer? On the same note: why am I allowed to do this: class...
11
by: asimorio | last post by:
Hi all, If I don't new up a pointer, can I delete it? see code below: void A::foo() { char* buffer; delete buffer; return; }
1
by: OutdoorWorldAdventures | last post by:
I have been trying to do any type of form that my web viewers can submit a picture and story for review to be submited to my website. I use Yahoo Business as my host and everything. I even tried...
5
by: fniles | last post by:
I am using VB.NET 2005. When I try to delete a folder that has files underneath it, it gave me "the directory is not empty" error. f = New IO.DirectoryInfo("C:\myfolder") If f.Exists Then...
1
by: psyvanz | last post by:
any code that can delete all records in just one click if you have a dataenvironment code it more good.. cause im working in this kind of code. like this: single delete code (not all in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...

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.