How can I get the application’s path in a .NET console application?

System.Reflection.Assembly.GetExecutingAssembly().Location1 Combine that with System.IO.Path.GetDirectoryName if all you want is the directory. 1As per Mr.Mindor’s comment:System.Reflection.Assembly.GetExecutingAssembly().Location returns where the executing assembly is currently located, which may or may not be where the assembly is located when not executing. In the case of shadow copying assemblies, you will get a path in a temp directory. System.Reflection.Assembly.GetExecutingAssembly().CodeBase will return the ‘permanent’ path … Read more

What’s the difference between session.persist() and session.save() in Hibernate?

From this forum post persist() is well defined. It makes a transient instance persistent. However, it doesn’t guarantee that the identifier value will be assigned to the persistent instance immediately, the assignment might happen at flush time. The spec doesn’t say that, which is the problem I have with persist(). persist() also guarantees that it will not execute an … Read more

What is the default font of Sublime Text?

On Linux it’s Monospace 10 pt. (the exact monospace font used may vary on different Linux distributions or versions), on Windows it’s Consolas 10 pt., and on OS X it’s Menlo Regular 12 pt. (The color scheme is Neon, the syntax highlighting is from PackageDev, and the font is Liberation Mono This information is found in the Packages/Default directory (where Packages is the directory opened by the Preferences → … Read more

Java Scanner doesn’t wait for user input

It’s possible that you are calling a method like nextInt() before. Thus a program like this: demonstatres the behavior you’re seeing. The problem is that nextInt() does not consume the ‘\n’, so the next call to nextLine() consumes it and then it’s waiting to read the input for y. You need to consume the ‘\n’ before calling nextLine(). (actually a better way would be to call … Read more

Categories io