Results 1 to 3 of 3

Thread: [2005] IO.Streamwriter issues

  1. #1

    Thread Starter
    Lively Member rguifarro's Avatar
    Join Date
    Aug 2006
    Location
    Central America
    Posts
    73

    [2005] IO.Streamwriter issues

    The thing is happening when i'm trying to write a file with this io. namespace.
    Don't know if haveing more than 1 IO. process affects one another?

    The error i'm getting says "" the file is already been use by another process". Can't get it to work. I'm creating the file then writeing on it but still nothing happens. Gonna include the vb code.

    Code:
            Dim myfile As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\dos2.txt"
            Dim fw As New IO.FileStream(Application.StartupPath + "\descarga.txt", IO.FileMode.Create, IO.FileAccess.Write)
            Dim sw1 As New IO.StreamWriter(fw)
            
    
            Tmr9.Interval = 1
            tenvios = 0
            envio = 0
    
            lstLOG.Items.Add(CStr(Now) + " Proceso iniciado......timer9 ")
            arch = CreateObject("Scripting.FileSystemObject")
            lstLOG.Items.Add(CStr(Now) + " Ordenando Archivos")
            lstLOG.Refresh()
            file = arch.opentextfile(myfile, 1) 'here just been open to later on be reading the lines on the textfile
            
            sw1.WriteLine("user")
            sw1.WriteLine("password")
            sw1.WriteLine("cd salida")
            sw1.WriteLine("mget *.pgp")
            
            Process.Start("C:\Documents and Settings\rguifarro\Mis documentos\Visual Studio 2005\Projects\BancomerProto\desc.mdb", AppWinStyle.Hide)
            
            i = 0
            While i = 0
                While Not file.AtEndOfStream
                    linea = file.readline
                    If Len(linea) > 3 Then
                        linea = Mid(linea, 1, Len(linea) - 1)
                        nomdesc = Microsoft.VisualBasic.Left(linea, (Len(linea) - 4))
                        tenvios = tenvios + 1
                        lstLOG.Items.Add(CStr(Now) + " Archivo " + linea + " Listo para Descarga")
                        sw1.WriteLine("y")
                        i = i + 1
                    End If
                End While
                If i = 0 Then
                    i = 100
                End If
            End While
            If i = 100 Then
                lstLOG.Items.Add(CStr(Now) + " No hay archivos para procesar.")
                Exit Sub
            End If
    
            sw1.WriteLine("bye")
            sw1.Close()      'here it should close the writer but nothing happens
            fw.Close()
            fw.Dispose()
            file.Close()

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [2005] IO.Streamwriter issues

    On what line is this error occuring?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Lively Member rguifarro's Avatar
    Join Date
    Aug 2006
    Location
    Central America
    Posts
    73

    Re: [2005] IO.Streamwriter issues

    This is the line where the error pops up:

    Code:
    Dim fw As New IO.FileStream(Application.StartupPath + "\descarga.txt", IO.FileMode.Create, IO.FileAccess.Write)
    It creats the file fine, but then it say that is in use, also the 1st IO process I'm useing I close the writer and the file text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width