In fact, creating a dummy file will not have much performance impact in most applications. Of course, if you have additional permissions to create, but not to destroy, you might get a little hairy ...
Guides are always convenient for random names (to avoid conflicts) - something like:
string file = Path.Combine(dir, Guid.NewGuid().ToString() + ".tmp"); // perhaps check File.Exists(file), but it would be a long-shot... bool canCreate; try { using (File.Create(file)) { } File.Delete(file); canCreate = true; } catch { canCreate = false; }
Marc gravell
source share