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

Home Posts Topics Members FAQ

how to close a jpg file so it can be deleted

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(filen ame) 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 File.deleteOnEx it(), the files are deleted
but I would rather use File.delete().
I suspect that the files are still open when I try
to delete them and that windows won't allow them to
be deleted if they are open.
How can I close the file?
I tried setting the reference to the File to null,
but that doesn't work.

Tks, phil.....
Jul 17 '05 #1
0 1652

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

Similar topics

0
1713
by: Peter A. Schott | last post by:
If I want to verify that a file has finished writing before deleting the remote file, what would be the best method? Current code on Python 2.4: #filename - remote FTP server File Name #NewFile - local file copy of the remote file #objFTP - standard ftplib.FTP object NewFile = open(os.path.join(InputPath, RemoteFileName), "wb")
6
1929
by: Sara Khalatbari | last post by:
Dear friends In a code, I'm opening a file to read. Like : lines = open(filename).readlines() & I'm never closing it. I'm not writing in that file, I just read it. Will it cause any problems if you open a file to read & never close it?
6
2043
by: Jonathan | last post by:
I am trying to upload a new version of a file that already exists on my web site. It asks me to overwrite and I choose yes. But when I go to the web page, even a half hour after the upload, the orginal content of the page is still there. I have tried uplaoding several times in IE and FTP voyager. There are no errors reported during the upload. FTP voyer is using binary upload for sure. Also, I deleted the file I am trying to update on...
4
47479
by: Bill | last post by:
I need help closing a CMD window when it is executed from Access. 1) The batch file is called from Access. 2) Access closes, 3) the batch runs a copy of the access database (creating a backup) 4) Once the copy is complete, the batch file opens the Access database again 5) EXIT should close out the cmd window but it does not execute that line
9
15746
by: John | last post by:
Hi All, I have encountered a problem with the ldb file of a database. When making changes to the backend databases I need exclusive access to make changes. I usually do this at night when all users have left the premises, but for the last couple of nights there are no users using the database and the ldb file is still visible even though I'm sure nobody is using the database. I have tried to manually delete the lbd file but the...
6
5284
by: Kiran | last post by:
Hi, I have program, which opens file at the startup and logs error messages to the file, file handle is closed at the end of the program. However if file is deleted in-between, program do not report any error while writing to the open file handle. On Windows, file shows-up again in explorer and automatically deleted finally when program ends. On Unix, same thing happens if file is on nfs mounted drive, but in this case, actual file is...
1
3655
by: Aaron | last post by:
Can someone please help me close this db connection. I know the connection is not closed because there;s a ldb file in my db folder. dbCommand.Connection.Open(); IDataReader myReader = dbCommand.ExecuteReader(); while (myReader.Read()) { return myReader.GetString(1); }
0
3897
by: bonita | last post by:
In my ASP.NET page, I have 2 checkboxes for users to choose which crystal report they want to display. These two reports use different tables. If report1 has been choosen and displayed in the crystal report, then I cannot check another checkbox to display report2 afterwards. If I close the website and open again, I can choose report2 and display as crystal report correct, but now I cannot check the checkbox1 to display report 1 afterwards....
6
3167
by: Zytan | last post by:
I ran through the VB Guided Tour some time ago. In particular, the "Managing Your Records: Using Data in Your Program" section: http://msdn2.microsoft.com/en-us/library/t25kbx0s(VS.80).aspx This explains how to create a SQL database, which is stored as an .mdf file: http://msdn2.microsoft.com/en-us/library/ms172599(VS.80).aspx It is just 4 or 5 addresses being stored. However, the database is 2,240 KB in size! To store 5 addresses? ...
0
8000
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,...
1
8145
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
8330
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
6815
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...
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();...
0
3960
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
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1328
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.