public NtStatus CreateFile(string fileName, FileAccess access, FileShare share, FileMode mode, FileOptions options, FileAttributes attributes, DokanFileInfo info) { try { ////Avoid pasting file by normal way if (BoschHelper.IsPastingFile(fileName, mode)) { return(DokanResult.AccessDenied); } var res = Wait(MainCreateFile(fileName, access, share, mode, options, info)); #if TRACE var readWriteAttributes = (access & DataAccess) == 0; if (!(readWriteAttributes || info.IsDirectory) || (res != DokanResult.Success && !(lastFilePath == fileName && res == DokanResult.FileNotFound))) { if (!(info.Context is IBlockStream)) { Log.Trace($"{fileName}\r\n Access:[{access}]\r\n Share:[{share}]\r\n Mode:[{mode}]\r\n Options:[{options}]\r\n Attr:[{attributes}]\r\nStatus:{res}"); } lastFilePath = fileName; } #endif return(res); } catch (Exception e) when(e.InnerException is FileNotFoundException) { Log.Error($"File not found: {fileName}\r\n Access:[{access}]\r\n Share:[{share}]\r\n Mode:[{mode}]\r\n Options:[{options}]\r\n Attr:[{attributes}]", e); return(DokanResult.FileNotFound); } catch (Exception e) when(e.InnerException is TimeoutException) { Log.Error($"Timeout: {fileName}\r\n Access:[{access}]\r\n Share:[{share}]\r\n Mode:[{mode}]\r\n Options:[{options}]\r\n Attr:[{attributes}]", e); return(NtStatus.Timeout); } catch (Exception e) { Log.Error($"Unexpected exception: {fileName}\r\n Access:[{access}]\r\n Share:[{share}]\r\n Mode:[{mode}]\r\n Options:[{options}]\r\n Attr:[{attributes}]", e); return(DokanResult.Error); } }