Cualquier ayuda, se agradece!
Las líneas del problema:
Código
( 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:
Código:
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:
Código
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) ' command to writleline 'Console.WriteLine("File Name: {0}", file.Name) 'Console.WriteLine("File Full Name: {0}", 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:
Código
.... 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) ' command to writleline 'Console.WriteLine("File Name: {0}", file.Name) 'Console.WriteLine("File Full Name: {0}", file.FullName) ' objWriter.Close() Next End If Next End Using ' Flush, close and dispose the objWriter ....