Validate a file name on Windows

Given the requirements specified in the previously cited MSDN documentation, the following regex should do a pretty good job: public static boolean isValidName(String text) { Pattern pattern = Pattern.compile( “# Match a valid Windows filename (unspecified file system). \n” + “^ # Anchor to start of string. \n” + “(?! # Assert filename is not: … Read more

How would you make a unique filename by adding a number?

public FileInfo MakeUnique(string path) { string dir = Path.GetDirectoryName(path); string fileName = Path.GetFileNameWithoutExtension(path); string fileExt = Path.GetExtension(path); for (int i = 1; ;++i) { if (!File.Exists(path)) return new FileInfo(path); path = Path.Combine(dir, fileName + ” ” + i + fileExt); } } Obviously, this is vulnerable to race conditions as noted in other answers.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)