FileStream disable Close()
问题 I'm creating a temporary file with the DeleteOnClose option: var fileStream = File.Create(Path.GetTempFileName(), 4096, FileOptions.DeleteOnClose); Another class(which I cannot modify) will write some data to this file: someObject.WriteDataToFile(fileStream); then I want to retrieve the data for further processing, close the stream, and let the file be automatically deleted. But someObject.WriteDataToFile(fileStream) also calls fileStream.Close() , which will delete the file, so I cannot