Is there a way of making strings file-path safe in c#?

Ugh, I hate it when people try to guess at which characters are valid. Besides being completely non-portable (always thinking about Mono), both of the earlier comments missed more 25 invalid characters. foreach (var c in Path.GetInvalidFileNameChars()) { fileName = fileName.Replace(c, ‘-‘); } Or in VB: ‘Clean just a filename Dim filename As String = … Read more

Why use os.path.join over string concatenation?

Portable Write filepath manipulations once and it works across many different platforms, for free. The delimiting character is abstracted away, making your job easier. Smart You no longer need to worry if that directory path had a trailing slash or not. os.path.join will add it if it needs to. Clear Using os.path.join makes it obvious … Read more

Check whether a path is valid in Python without creating a file at the path’s target

tl;dr Call the is_path_exists_or_creatable() function defined below. Strictly Python 3. That’s just how we roll. A Tale of Two Questions The question of “How do I test pathname validity and, for valid pathnames, the existence or writability of those paths?” is clearly two separate questions. Both are interesting, and neither have received a genuinely satisfactory … Read more

mkdir if not exists using golang

Okay I figured it out thanks to this question/answer import( “os” “path/filepath” ) newpath := filepath.Join(“.”, “public”) err := os.MkdirAll(newpath, os.ModePerm) // TODO: handle error Relevant Go doc for MkdirAll: MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. … If path is already a … Read more

Command copy exited with code 4 when building – Visual Studio restart solves it

While /C may ignore errors, it might not be the real solution as there could be files that MUST be copied in order for the build to be successful. The most common issue is the missing quotes around the pre-defined command tags (such as $TargetDir). When one creates various branches and paths in code or … Read more

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