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