Rename(old,new) issue with msgbox

  • Thread starter Thread starter Jay at SCA
  • Start date Start date
J

Jay at SCA

I've been having the following issue with a windows
service I've created in vb.net (.net fw 1.1):

Basically, my service monitors a folder for the creation
of any new files of a particular type and renames them
using the "Rename(oldfilename,newfilename)" function.
Unfortunately, this function only seems to work if and
only if it is preceeded by a 'msgbox("<some text>")'.

ie. If I have the following the service sees the file
created in the folder and renames it appropriately:
MsgBox("e.name variable etemp is " & etemp)
Rename(etemp, NewFName) 'Rename the file

but if I comment out the 'msgbox' line and only have the
"Rename(etemp, NewFName) 'Rename the file"
line, the service only sees the file created but does not
rename it.

I've using System.IO.File.Move(etemp, NewFName) in place
of Rename but with the same results. I'm stumped as to
why the presence of a msgbox should cause my rename to
succeed or fail.

-ANY- help in this would be greatly appreciated.

Thanks,

Jay
(e-mail address removed)
 
I'm stumped as to
why the presence of a msgbox should cause my rename to
succeed or fail.

I would guess that the service was trying to rename the file before it was
finished being written. Adding the MsgBox may have just taken up enough
extra time to allow the file to be completely written.

Instead of using a MsgBox, try using Thread.Sleep with various amounts of
time to see if that is the case.

Just a thought

Chris
 
Back
Top