UnauthorizedAccessException on creating file after deletion using FileStream
I am facing an issue on client system. On trying to reproduce it in a sample code I have reproduced it. Here's the sample code Imports System.IO Public Class Form1 Private _lock As New Object Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim t As New Threading.Thread(AddressOf createFile) With t .IsBackground = True .Name = Guid.NewGuid.ToString .Start() End With End Sub Private Sub createFile() Dim path As String = "D:\SomeFile.txt" For i As Integer = 0 To 1000 SyncLock _lock If File.Exists(path) Then File.Delete(path) Using fs As