How can I make make the following code run asynchronously without having to create an extra thread on the thread pool (in other words without Task.Run(...)
)?
Directory.CreateDirectory("\\host\someNetworkDirectory");
Ideally, I would like to use it like this:
async SomeMethod(){
//...
await Directory.CreateDirectoryAsync("\\host\someNetworkDirectory");
// stuff to do after ensuring the directory exists
//...
}
I tried this answer (which suggest using FileSystemWatcher
) but it does not work for folders.