Hi
I am appending two files using following code.
When I am running this code by using F11 , this works fine. But when running without breakpoints, it throws an exception by saying "appendfile is being used by another process ". I think this occurs at deletion of appendfile before it is appended to sourcefile. What can I use to prevent this from happening? Any help will be grateful...Will Applicatio.Doev ents() or sleep the current thread is a feasibile solution..?
Thanks
I am appending two files using following code.
Code:
Try 'appending Using fs As New FileStream(sourceFile, FileMode.Append, FileAccess.Write) Dim buffer() As Byte = File.ReadAllBytes(appendFile) fs.Write(buffer, 0, buffer.Length) fs.Flush() End Using 'Delete the second file If (File.Exists(appendFile)) Then File.Delete(appendFile) End If Catch ex As Exception End Try
Thanks
Comment