Hi folks,
im using VB NET2008 and have the following situation:
my code calls an external application. that application, that I dont have management, populates an external text file. I can only go on with my code when this text files is released by the external application. I tried to rename this file to check if it is already been released or not but it doen not work. i notice that the external application open and closes many times until it has been finished so meanwhile, the function returns true but it has not been finished. I must try something like verifying if the size of the file has been stopped growing or something like that... have a made my self clear ?
the code im using is :
Shared Function FileIsLocked(ByVal fileFullPathName As String) As Boolean
Dim isLocked As Boolean = False
Dim fileObj As New System.IO.FileInfo(fileFullPathName)
Try
fileObj.MoveTo("c:\teste\gerados\saida_ok.txt")
MsgBox("consegui renomear")
Catch
isLocked = True
End Try
Return isLocked
End Function
startInfo = New System.Diagnostics.ProcessStartInfo("C:\teste\gerados\converte MS para TXT.exe")
pStart.StartInfo = startInfo
pStart.Start()
While Not System.IO.File.Exists("c:\teste\gerados\saida.txt")
Dim a As String
End While
While FileIsLocked("c:\teste\gerados\saida.txt")
Dim a As String
End While
startInfo = New System.Diagnostics.ProcessStartInfo("C:\teste\gerados\fecha DL.exe")
pStart.StartInfo = startInfo
pStart.Start()
im using VB NET2008 and have the following situation:
my code calls an external application. that application, that I dont have management, populates an external text file. I can only go on with my code when this text files is released by the external application. I tried to rename this file to check if it is already been released or not but it doen not work. i notice that the external application open and closes many times until it has been finished so meanwhile, the function returns true but it has not been finished. I must try something like verifying if the size of the file has been stopped growing or something like that... have a made my self clear ?
the code im using is :
Shared Function FileIsLocked(ByVal fileFullPathName As String) As Boolean
Dim isLocked As Boolean = False
Dim fileObj As New System.IO.FileInfo(fileFullPathName)
Try
fileObj.MoveTo("c:\teste\gerados\saida_ok.txt")
MsgBox("consegui renomear")
Catch
isLocked = True
End Try
Return isLocked
End Function
startInfo = New System.Diagnostics.ProcessStartInfo("C:\teste\gerados\converte MS para TXT.exe")
pStart.StartInfo = startInfo
pStart.Start()
While Not System.IO.File.Exists("c:\teste\gerados\saida.txt")
Dim a As String
End While
While FileIsLocked("c:\teste\gerados\saida.txt")
Dim a As String
End While
startInfo = New System.Diagnostics.ProcessStartInfo("C:\teste\gerados\fecha DL.exe")
pStart.StartInfo = startInfo
pStart.Start()