Convert a filename to a file:// URL
For completeness, in Python 3.4+, you should do: import pathlib pathlib.Path(absolute_path_string).as_uri()
For completeness, in Python 3.4+, you should do: import pathlib pathlib.Path(absolute_path_string).as_uri()
Use quotes: resp.addHeader(“Content-Disposition”, “inline; filename=\”” + fileName + “\””);
Use OpenFileDialog.SafeFileName OpenFileDialog.SafeFileName Gets the file name and extension for the file selected in the dialog box. The file name does not include the path.
On Android (at least by default) the file names encoded as UTF-8. Looks like reserved file name characters depend on filesystem mounted (http://en.wikipedia.org/wiki/Filename). I considered as reserved: private static final String ReservedChars = “|\\?*<\”:>+[]/'”;
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
You should take the spaces out of the filename. Because the filename is used as the identifier for imported modules (i.e. foo.py will be imported as foo) and Python identifiers can’t have spaces, this isn’t supported by the import statement. If you really need to do this for some reason, you can use the __import__ … Read more
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.
I ran into the same problem, but wasn’t willing to rename or delete these files. So here’s a workaround in case you can live without accessing those files using a sparse-checkout: Go to the .git folder in your repo and open the file config. (You can also edit your configuration using tortoise-git, but I havn’t … Read more
I found a very similar character to a colon, “꞉” it is a unicode character called a Modifier Letter Colon. This has no space like the fullwidth colon and is pretty much exactly the same as a regular colon but the symbol works. You can either copy and paste it from above or you can … Read more
It is specified in an http header content-disposition. So to extract the name you would do: import re d = r.headers[‘content-disposition’] fname = re.findall(“filename=(.+)”, d)[0] Name extracted from the string via regular expression (re module).