473,795 Members | 3,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ic o" to my imagelist...
.... hope my english working well in explaining myself...

-- it works this way:

foreach (System.IO.Dire ctoryInfo subdir in dir.GetDirector ies())
{
imageList.Image s.Add ( System.Drawing. Image.FromFile( subdir.FullName +
@"\picture.ico" ) );
System.Windows. Forms.ListViewI tem lvi = new ListViewItem(su bdir.Name,
imagelist.Image s.Count - 1);
listView.Items. Add(lvi);
}

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

System.Windows. Forms.ListViewI tem lvi = listView.Select edItems[0];
System.IO.Direc toryInfo di = (System.IO.Dire ctoryInfo) lvi.Tag;
int i = listView.Items. IndexOf(lvi);
listView.Items. Remove(lvi);
System.Drawing. Image Image = imageList.Image s[i];
imageList.Image s.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 4533
when time comes i decide to delete one of those sub-directories:

System.Windows. Forms.ListViewI tem lvi = listView.Select edItems[0];
System.IO.Direc toryInfo di = (System.IO.Dire ctoryInfo) lvi.Tag;
int i = listView.Items. IndexOf(lvi);
listView.Items. Remove(lvi);
System.Drawing. Image Image = imageList.Image s[i];
imageList.Image s.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.ic o" is used by another program...
Nov 16 '05 #3

"David" <da*******@hotm ail.com> wrote in message
news:uz******** ******@TK2MSFTN GP11.phx.gbl...
same exeption :(((
"picture.ic o" 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
28519
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 is the command for the same. thanks Regards umesh
0
2104
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...
14
2422
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 the list elements; the list is arbitrary long. Something like this: class ListElem { char Datum;
2
4750
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...
21
18622
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 probna {
11
2370
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
3321
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 manipulating the Guestbook so that people could enter this information but I want it to were other people will not be able to view the entries like a guestbook. I've never worked with PHP until now and I've missed on every shot so far. I want to...
5
33199
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 f.Delete() --error "the directory is not empty" End If How can I delete a folder with files underneath it ? Thank you.
1
2283
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 records) dataenvironment1.command1.delete thats all i can do... i want to know how to create a code that can delete all records code in just a single click... of a command button..
0
10435
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
10213
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...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6779
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();...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2920
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.