PERMISSION DENIED
                    Olá Pessoal,
Estou fazendo a integração com o componente ACBrNFeMonitor...
quando envio qualqer comando chamo uma função para ler o arquivo de retorno, nessa função tem um laço while aguardando o arquivo e é aà que está dando o erro.
Como demora para retornar, da o erro mencionado na Sub btnStatus_Click.
Alguém tem uma sugestão de como permanecer na função LeArquivo até que o arquivo seja criado?
Talves usando o Timer1, não sei como usar o Timer1.
            Estou fazendo a integração com o componente ACBrNFeMonitor...
quando envio qualqer comando chamo uma função para ler o arquivo de retorno, nessa função tem um laço while aguardando o arquivo e é aà que está dando o erro.
  Private Sub btnStatus_Click()
On Error GoTo Error
   Kill vPathMonitor & [Ô]\SAINFE.TXT[Ô]
   Open vPathMonitor & [Ô]\ENTNFE.TXT[Ô] For Output As #1
   cConteudo = [Ô]NFe.StatusServico[Ô]
   Print #1, cConteudo
   Close #1
   
   LeArquivo ([Ô]SAINFE.TXT[Ô])
   
   Exit Sub
   
Error:
   MsgBox Err.Description
End Sub
   Private Function LeArquivo(Arquivo As String)
Dim vLinha As String, cMensagem As String, OK As Boolean
      
   While OK = False
      If Dir(vPathMonitor & [Ô]\[Ô] & Arquivo) <> [Ô][Ô] Then
         OK = True
      
      End If
      
   Wend
   
   Open vPathMonitor & [Ô]\[Ô] & Arquivo For Input As #1
   
   DoEvents
   
   Do While Not EOF(1)
      Line Input #1, vLinha
      If cMensagem <> [Ô][Ô] Then
         cMensagem = cMensagem & vbCr & vLinha
         Exit Do
      
      End If
      
      If InStr(vLinha, [Ô]ERRO:[Ô]) > 0 Then
         cMensagem = vLinha
      
      End If
      
      If InStr(vLinha, [Ô]OK: Email enviado com sucesso[Ô]) > 0 Then
         cMensagem = vLinha
      
      End If
      
   Loop
   
   If cMensagem <> [Ô][Ô] Then
      MsgBox cMensagem, , [Ô]Atenção![Ô]
   
   End If
   
   Close #1
End Function Como demora para retornar, da o erro mencionado na Sub btnStatus_Click.
Alguém tem uma sugestão de como permanecer na função LeArquivo até que o arquivo seja criado?
Talves usando o Timer1, não sei como usar o Timer1.
                    Provavelmente isso ocorre quando o programa está aberto e voce tenta compilar ele, vá em Gerenciador de tarefas e verifique..
                
            Citação::
Provavelmente isso ocorre quando o programa está aberto e voce tenta compilar ele, vá em Gerenciador de tarefas e verifique..
Adilson,
O programa não está aberto, já verifiquei.
Estou usando o componente ACBrNFeMonitor, e faço a as transações por arquivos textos, toda vez que envio um comando (ENTNFE.TXT) o componente me responde (SAINFE.TXT).
Envio o comando e chamo a função LeArquivo que vai ler o arquivo (SAIFNE.TXT), o problema é que o componente demora para dar a resposta, aà fico no laço While OK = False, é quado ocorre o erro na Sub que chamou.
[txt-color=#e80000]Obs.: O que preciso é esperar um instante para chamar a função LeArquivo, mas não sei como, vc saberia o que posso fazer?
Será que ninguem usa esse componente para enviar NFe?
Usei ele no Clipper e está funcionando muito bem, agora estou desenvolvendo a nova versão no VB6 e preciso de um componente que faça a conunicação com a SEFAZ!
[/txt-color]
Obrigado,
                    Pessoal,
Acho que descobri o motivo do erro, minha função tenta abrir o arquivo aind quando o componente está inserindo dados nele, por isso [Ô]Permissão negada[Ô].
Tem outra opção de abertura de arquivos .txt no VB6?
            Acho que descobri o motivo do erro, minha função tenta abrir o arquivo aind quando o componente está inserindo dados nele, por isso [Ô]Permissão negada[Ô].
Tem outra opção de abertura de arquivos .txt no VB6?
                    Resolvido ...
Usei uma Sub que peguei aqui no forum:
            Usei uma Sub que peguei aqui no forum:
  [ô]//--------------------------------------------------------------------
[ô]// PROPOSITO:
[ô]// Dar Pause or delay em um PROCEDIMENTO especificando os segundos
[ô]//
[ô]// ARGUMENTS:
[ô]// Number of seconds. May use fractions in a decimal format (#.##)
[ô]//
[ô]// COMMENTS:
[ô]// Timer() returns a Single value rounded to the nearest 1/100 of a
[ô]// second like a stopwatch. Also, Timer() has a [Ô]bug[Ô] - it resets
[ô]// itself at midnight. Therefore we need to adjust for this, using
[ô]// some sort of counter. The simplest way is to concatenate the day
[ô]// in front of it with Day(Date) but then the days get reset when the
[ô]// month changes, and of course we need to adjust when the months are
[ô]// reset by the changing year. Fortunately that[ô]s as far as we have
[ô]// to go. To avoid an extremely large number by concatenating one in
[ô]// front of the other, we add the different parts of the Date together
[ô]// and then concatenate with the sum.
[ô]//--------------------------------------------------------------------
Public Sub EventPause(sngSeconds As Single)
Dim dblTotal As Double, dblDateCounter As Double, sngStart As Single
Dim dblReset As Double, sngTotalSecs As Single, intTemp As Integer
   [ô]// For our purposes, it[ô]s better to concatenate five zeros onto the
   [ô]//  end of our date counter, then ADD any Timer values to it.
   dblDateCounter = ((Year(Date) + Month(Date) + Day(Date)) _
     & 0 & 0 & 0 & 0 & 0)
   [ô]// Initialize start time.
   sngStart = Timer
   [ô]// We also need to adjust for the possible resetting of Timer()
   [ô]//  (such as if the Time happens to be just before midnight) when
   [ô]//  adding the Pause time onto the Start time. The folowing formula
   [ô]//  takes ANY value of the total seconds, whether it[ô]s above or below
   [ô]//  the 86400 limit, and converts it to a format compatible to the
   [ô]//  date counter.
   sngTotalSecs = (sngStart + sngSeconds)
   intTemp = (sngTotalSecs \ 86400)   [ô]// Return the integer portion only
   dblReset = (intTemp * 100000) + (sngTotalSecs - (intTemp * 86400))
   [ô]// Now we can initialize our total time.
   dblTotal = dblDateCounter + dblReset
   
   [ô]// Timer loop
   Do
      DoEvents        [ô]// Make sure any other tasks get some attention
      [ô]// For this to work properly, we cannot create a variable with the
      [ô]//  concatenated expression and plug it in unless we reset the variable
      [ô]//  during the loop. Much better to do it like this:
   Loop While (dblDateCounter + Timer) < dblTotal
    
End Sub
 
                
                        Tópico encerrado , respostas não são mais permitidas