473,385 Members | 1,693 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,385 software developers and data experts.

File delete

Hi,

When I use the following code I have a error that the file is in use

If File.Exists("c:\RegistratieMD\images\" + Me.txtBarcode.Text + ".jpg")
= True Then
File.Delete("c:\RegistratieMD\images\" + Me.txtBarcode.Text+ ".jpg")
End If

How can I solve this problem

Thx

JoskeXP
Nov 20 '05 #1
5 1486
Basically you can't.. if the file is in use you won't be able to delete it
until it gets closed.

--
Best Regards
Yanick Lefebvre
"JoskeXP" <jo*****@nospam.hotmail.com> a écrit dans le message de
news:Xn**********************************@195.130. 132.70...
Hi,

When I use the following code I have a error that the file is in use

If File.Exists("c:\RegistratieMD\images\" + Me.txtBarcode.Text + ".jpg")
= True Then
File.Delete("c:\RegistratieMD\images\" + Me.txtBarcode.Text+ ".jpg")
End If

How can I solve this problem

Thx

JoskeXP

Nov 20 '05 #2
"Zoury" <ya*************@hotmail.com> wrote in
news:O8**************@tk2msftngp13.phx.gbl:
Basically you can't.. if the file is in use you won't be able to
delete it until it gets closed.


HI,

I used the file before for filling a picture box with this code

imgFotoOK.Image = Image.FromFile("c:\RegistratieMD\images\" +
Me.txtBarcode.Text + ".jpg")

and now I have to delete this file and make a new file (with the same name)
with another picture.

How can I do this than.

Thx

JoskeXP

Nov 20 '05 #3
* JoskeXP <jo*****@nospam.hotmail.com> scripsit:
I used the file before for filling a picture box with this code

imgFotoOK.Image = Image.FromFile("c:\RegistratieMD\images\" +
Me.txtBarcode.Text + ".jpg")

and now I have to delete this file and make a new file (with the same name)
with another picture.


Create a new 'Bitmap' object, draw the original bitmap into the new
bitmap, then dispose the original 'Bitmap' object by calling its
'Dispose' method and assign the new bitmap to the control's 'Image'
property.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Hi,

Open the bitmap with a filestream.

Dim fs As New System.IO.FileStream("C:\deleteme.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)
fs.Close()
picturebox1.image = bm
System.IO.File.Delete("C:\deleteme.bmp")

Ken
----------------

"JoskeXP" <jo*****@nospam.hotmail.com> wrote in message
news:Xn**********************************@195.130. 132.70:
"Zoury" <HYPERLINK
"mailto:ya*************@hotmail.com"ya************ *@hotmail.com> wrote in
news:O8**************@tk2msftngp13.phx.gbl:

Basically you can't.. if the file is in use you won't be able to
delete it until it gets closed.

HI,

I used the file before for filling a picture box with this code

imgFotoOK.Image = Image.FromFile("c:\RegistratieMD\images\" +
Me.txtBarcode.Text + ".jpg")

and now I have to delete this file and make a new file (with the same
name)
with another picture.

How can I do this than.

Thx

JoskeXP


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 262.10.6 - Release Date: 5/28/2004
Nov 20 '05 #5
Ken Tucker [MVP] <vb***@bellsouth.net> wrote in
news:#C*************@tk2msftngp13.phx.gbl:
Hi,

Open the bitmap with a filestream.

Dim fs As New System.IO.FileStream("C:\deleteme.bmp",
IO.FileMode.Open)
Dim bm As New Bitmap(fs)
fs.Close()
picturebox1.image = bm
System.IO.File.Delete("C:\deleteme.bmp")

Ken
----------------

"JoskeXP" <jo*****@nospam.hotmail.com> wrote in message
news:Xn**********************************@195.130. 132.70:
"Zoury" <HYPERLINK
"mailto:ya*************@hotmail.com"ya************ *@hotmail.com>
wrote in news:O8**************@tk2msftngp13.phx.gbl:

> Basically you can't.. if the file is in use you won't be able to
> delete it until it gets closed.
>


Hi,

works perfect

Thanks

JoskeXP
Nov 20 '05 #6

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

Similar topics

2
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
1
by: dominic | last post by:
Hi all, I'm trying to create a temp file by copying from an existing file, perform some operation on the temp file, and then delete it. The code I used is as follow: // First, to copy the...
5
by: Hal Vaughan | last post by:
I have to go through and delete a bunch of files after another program used them. I'm doing: File oFile = new File(fileName); oFile.delete(); if (oFile.exists()) { oFile.deleteOnExit(); } ...
48
by: Joseph | last post by:
Hi I'm writing a commercial program which must be reliable. It has to do some basic reading and writing to and from files on the hard disk, and also to a floppy. I have foreseen a potential...
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....
23
by: da Vinci | last post by:
Greetings, Onwards with the school studying. Working on a program and need to delete a file from a known location on the hard drive but cannot get anything I do to work. I have tried to use...
7
by: Diggler | last post by:
I have a web application that allows a user to manage files on the server. On the page is a counter that tells them how many files are in their folder. When you delete a file from the folder using...
3
by: Joe | last post by:
Hi, I have written a webpage that allows a user to delete files in asp.net with I am having a small problem. To access this page a user has to login via login.aspx page. After successful...
12
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...
9
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)...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.