Write a file in a specific path in C++

Specify the full path in the constructor of the stream, this can be an absolute path or a relative path. (relative to where the program is run from) The streams destructor closes the file for you at the end of the function where the object was created(since ofstream is a class). Explicit closes are a … Read more

Determining location of JVM executable during runtime

You could always just use os.name to check if the user is running Windows or not. That’ll work on OS X, Linux and Windows at String jvm_location; if (System.getProperty(“os.name”).startsWith(“Win”)) { jvm_location = System.getProperties().getProperty(“java.home”) + File.separator + “bin” + File.separator + “java.exe”; } else { jvm_location = System.getProperties().getProperty(“java.home”) + File.separator + “bin” + File.separator + “java”; … Read more

Node npm windows file paths are too long to install packages

The problem with deeply nested folders on Windows has been mostly solved starting with npm version 3.x. According to npm: .npm@3 makes the install “maximally flat” by hoisting everything it can to the top level node_modules. This means nesting only occurs on conflicts and as such, trees should never get very deep. As such, the … Read more

“invalid path 0 files copied” Error while using xcopy command

Original answer Remove the ending backslash from the source folder path C:\Windows\System32\xcopy.exe /Y “C:\Users\Ryan\Desktop\mmars_pub” “C:\Users\Ryan\Desktop\Dropbox\MMARS\mmars_pub\” edited 2015/10/01 While the original question used a literal path, and the indicated solution will solve the problem, there is another option. For literal paths and in cases where the path is inside a variable and could (or not) end … Read more

How to escape the backslashes and the automatically generated escape character in file path in java

Use a double slash in Java string literal to escape a slash : String s = “c:\\new folder\\title.csv”; If an end user enters a string in a JFileChooser, the string variable will contain all the characters entered by the user. Escaping is only needed when using String literals in Java source code. And use a … Read more

VBScript to open a dialog to select a filepath

There is another solution I found interesting from MS TechNet less customization but gets what you wanted to achieve. This returns the full path of the selected file. Set wShell=CreateObject(“WScript.Shell”) Set oExec=wShell.Exec(“mshta.exe “”about:<input type=file id=FILE><script>FILE.click();new ActiveXObject(‘Scripting.FileSystemObject’).GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>”””) sFileSelected = oExec.StdOut.ReadLine wscript.echo sFileSelected

How to get Desktop location?

On Unix or Linux: import os desktop = os.path.join(os.path.join(os.path.expanduser(‘~’)), ‘Desktop’) on Windows: import os desktop = os.path.join(os.path.join(os.environ[‘USERPROFILE’]), ‘Desktop’) and to add in your command: shutil.copy(txtName, desktop)

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