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

delete or close a file which is used by another process

ASP (VB.net)
Good day. I re-use the same file name for sms information which gets uploaded to a FTP (sms) server. The file name is every time closed (seems this is not the case) When trying to re do this, an error is trapped that says the file is in use by another process. I checked the task manager after exiting out of the dot NET enviroment. The process causing this is ASPNET_WP.exe. This process I have to end several times as it seems like multiple threads are running (which obviously cause the file to be in use. After several atempts to end the process, the file is "available" for editing or deletion.

The file "process" is happening in a loop, which includes fileclose process.
Could anyone give advise as to how to either prevent "threading" if this is the case or killing / deletion / closing the file.

This is how the loop looks like:

Dim fn As String
For c = 1 To lbNames.Items.Count
nr = Trim(lbNames.Items(c - 1).Value().Substring(32, 12))
fn = GetAppPath() + "cellsms.req"
FileOpen(c, fn, OpenMode.Output, OpenAccess.Write)
Print(c, "Cell SMS Message CSA Team" & vbCrLf) 'Account code forbilling
Print(c, "Yes" & vbCrLf) 'Delivery report required
Print(c, "Default" & vbCrLf) 'Unknown , just use Default
Print(c, nr & vbCrLf) 'Cellular tel number
Print(c, txtarea.Value & vbCrLf) 'SMS Message
FileClose(c)
sendmsg(True, totnum, fn)
lbNames.Items.Remove(c - 1)
FileClose(c) 'if the file is for whatever reason still open
Next c
Sep 20 '06 #1
0 3167

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Richard Arthur | last post by:
This is a weird problem. 1) I use MediaDet to save a bitmap in a temporary file. 2) I create a bitmap using that temporary file's name. 3) I use the bitmap. 4) I want to destroy the file when...
7
by: Smitty | last post by:
I have a function that imports an Excel file into an Access table using SQL. I then close the OleDataReader and the OleDbConnection, then dispose the OleDbCommand, then OleDbConnection. The calling...
4
by: news.microsoft.com | last post by:
I need some help here guys.... i have been simply trying to delete a file from the webserver using asp.net using the following code. System.IO.File.Delete(FullPath); however the error message...
3
by: guoqi zheng | last post by:
Dear sir, There is an import tool on my web application, user can upload Ms Access file, the file is saved at a temp folder on the server. After the import is finished, for security reason, I...
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...
11
by: Tark Siala | last post by:
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(PhotoFullFileNameX) Dim...
22
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. ...
1
by: Tod Birdsall | last post by:
I am using Microsoft Office Document Imaging (MODI) with great success. However, when execute the following code, I get the error "The process cannot access the file 'myFile.tif'" (File name has...
2
by: SCPOS | last post by:
Cannot delete X: It is being used by another person or program. Close any programs that might be using the file and try again. Of course I have tried closing any programs I know of that may be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.