Waiting for a file to be created in C #

Is there a built-in method to wait for a file to be created in C #? How about a file being fully recorded?

I baked my own by repeatedly trying File.OpenRead () in the file until it succeeds (and does not work with a timeout), but rotating the file does not seem to work correctly. I guess that there was a baked method in .NET, but I can not find it.

+3
source share
4 answers

How to use the FileSystemWatcher component?

This class “watches” a given directory or file and can generate events when something (you can determine what) happened.

+10
source

File.Create Close. :

File.Create(savePath).Close();
+3

FileSystemWatcher , , , , .. waitign .

, , , , , . , , ... .

+1

FileSysWatcher . "" , .

Is there an alternative so that we can be sure that we are not opening the file before it is completely written to disk and closed?

+1
source

Source: https://habr.com/ru/post/1702654/


All Articles