Tengo problemas al intentar escribir datos en un archivo de texto...
Cualquier ayuda, se agradece!
Las líneas del problema:
            If System.IO.File.Exists(Temp_file) = True Then System.IO.File.Delete(Temp_file)
            System.IO.File.Create(Temp_file)
( Cualquiera de las dos líneas, si elimino una, me da el mismo error en la otra, pero el archivo si que me lo llega a crear (vacío) )
El error:
The process cannot access the file 'C:\Users\Administrador\AppData\Local\Temp\PlayList_temp.txt' because it is being used by another process.
El sub:
  Public Sub C1Button2_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If Not playerargs = Nothing Then
            Dim Str As String
            Dim Pattern As String = ControlChars.Quote
            Dim ArgsArray() As String
            Dim Temp_file As String = System.IO.Path.GetTempPath & "\PlayList_temp.txt"
            Dim objWriter As New System.IO.StreamWriter(Temp_file)
            Str = Replace(playerargs, " " & ControlChars.Quote, "")
            ArgsArray = Split(Str, Pattern)
            If System.IO.File.Exists(Temp_file) = True Then System.IO.File.Delete(Temp_file)
            System.IO.File.Create(Temp_file)
        For Each folder In ArgsArray
            If Not folder = Nothing Then
                Dim di As New IO.DirectoryInfo(folder)
                Dim files As IO.FileInfo() = di.GetFiles("*")
                    Dim file As IO.FileInfo
                For Each file In files
                    ' command to writleline
                    'Console.WriteLine("File Name: {0}", file.Name)
                    'Console.WriteLine("File Full Name: {0}", file.FullName)
                    objWriter.Write(file.FullName)
                    objWriter.Close()
                Next
            End If
            Next
        If randomize.Checked = True Then
                RandomiseFile(Temp_file)
        End If
        Process.Start(userSelectedPlayerFilePath, playerargs)
        If autoclose.Checked = True Then
            Me.Close()
        End If
        Else
        MessageBox.Show("You must select at least one folder...", My.Settings.APPName)
        End If
    End Sub
EDITO: Ya está, solucionado:
....
If Not playerargs = Nothing Then
    ....
    Dim Temp_file As String = System.IO.Path.GetTempPath & "\PlayList_temp.txt"
    Using objWriter As New System.IO.StreamWriter(Temp_file, false)
        For Each folder In ArgsArray
            If Not folder = Nothing Then
                Dim di As New IO.DirectoryInfo(folder)
                Dim files As IO.FileInfo() = di.GetFiles("*")
                Dim file As IO.FileInfo
                For Each file In files
                    ' command to writleline
                    'Console.WriteLine("File Name: {0}", file.Name)
                    'Console.WriteLine("File Full Name: {0}", file.FullName)
                    objWriter.Write(file.FullName)
                    ' objWriter.Close() 
                Next
            End If
        Next
    End Using ' Flush, close and dispose the objWriter
    ....