filepath

this.getClass().getResource(“”).getPath() returns an incorrect path

白昼怎懂夜的黑 提交于 2019-12-04 09:34:27
问题 I am currently making a small simple Java program for my Computer Science Final, which needs to get the path of the current running class. The class files are in the C:\2013\game\ folder. To get this path, I call this code segment in my main class constructor: public game(){ String testPath = this.getClass().getResource("").getPath(); //Rest of game } However, this command instead returns this String: "/" despite the correct output being "C:/2013/game" Additionally, I attempted to rectify

Add unique suffix to file name

余生颓废 提交于 2019-12-04 09:07:47
Sometimes I need to ensure I'm not overwriting an existing file when saving some data, and I'd like to use a function that appends a suffix similar to how a browser does it - if dir/file.txt exists, it becomes dir/file (1).txt . This is an implementation I've made, that uses Qt functions: // Adds a unique suffix to a file name so no existing file has the same file // name. Can be used to avoid overwriting existing files. Works for both // files/directories, and both relative/absolute paths. The suffix is in the // form - "path/to/file.tar.gz", "path/to/file (1).tar.gz", // "path/to/file (2)

Transformer library that comes with Java converts spaces in file paths to %20

大兔子大兔子 提交于 2019-12-04 07:22:08
Here is a test application that writes out XML Files. Why are the spaces in my path being converted to %20 ? public class XmlTest { public static void main(String[] args) { String filename = "C:\\New Folder\\test.xml"; try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty(OutputKeys.INDENT, "yes");

get Path name from Uri Android Lollipop

*爱你&永不变心* 提交于 2019-12-04 05:30:56
问题 Lollipop version. I used this code to determine file path from Uri. Works fine, but if I choose file from a Downloaded app - getRealPathFromURI_API19 function does not work for me. whole Id for this case equals /document/4 for example, and my app was crashed. Ok, I made some changes for this function and "id" for Uri "/document/4" now equals 4, but function returns null. Is it possible get file path for choosed image from any app? I need file path for ExifInterface. 回答1: Works fine Only for

How Do I Set PHP to Download File to a Specific Directory?

戏子无情 提交于 2019-12-04 04:28:18
问题 I am looking for some general guidance on this one... I have created a PHP script that uses cURL to download a csv file. Currently, it downloads the file to my computer when I run the script. I would like to amend the download path to route it to a directory on my web host. Is there any easy way to do this with PHP? Here is a quick summary of the PHP script that downloads the CSV file: <?php $ch = curl_init(); //this is where I submit the form to download the csv file... curl_close ($ch);

Drive letter from URI type file path in C#

一个人想着一个人 提交于 2019-12-04 02:33:21
What is the easiest way to get the drive letter from a URI type file path such as file:///D:/Directory/File.txt I know I can do (path here is a string containing the text above) path = path.Replace(@"file:///", String.Empty); path = System.IO.Path.GetPathRoot(path); but it feels a bit clumsy. Is there a way to do it without using String.Replace or similar? var uri = new Uri("file:///D:/Directory/File.txt"); if (uri.IsFile) { DriveInfo di = new DriveInfo(uri.LocalPath); var driveName = di.Name; // Result: D:\\ } This can be done using the following code: string path = "file:///D:/Directory/File

How to easily get network path to the file you are working on?

浪尽此生 提交于 2019-12-03 17:45:33
问题 In Excel 2003 there used to be a command that I added to my toolbar that was called Address (if I remember correctly) and it would show the fully-qualified network path to the file I had open. For example: \\ads\IT-DEPT-DFS\data\Users\someguy\somefile.xls This made it easy to grab this string and pop it in an email when you wanted to share the file with a coworker. I don't see this option in Excel 2010 but find myself needing to send/receive Excel files a lot now. Coworkers will give vague

How do you determine the physical path of a file without an HttpContext?

情到浓时终转凉″ 提交于 2019-12-03 16:46:34
问题 I have some processes that run without an HttpContext in an ASP.NET MVC web application. This process needs to be able to determine the physical path to the Contents directory of the application for reading/writing data. But, since it is without an HttpContext, I don't get to use fancy things like Server.MapPath and such. Suggestions? 回答1: In a website, it is best to use HttpRuntime.AppDomainAppPath, because in certain moments of the execution path (i.e. when the site starts up), there's no

Android 7 nougat, how to get the file path from uri of incoming intent?

£可爱£侵袭症+ 提交于 2019-12-03 16:06:51
FileProvider:- Setting up file sharing I know that change the file policy in android nougat. The wanted app that file share to other apps generate the uri by FileProvider. The uri format is content://com.example.myapp.fileprovider/myimages/default_image.jpg . I want know that how can I get filepath from the uri that generate by FileProvider.getUriForFile() . because the my app is need to know the physical filepath in order to save, load, readinfo, etc. is it possible [In short] My app received the intent uri by other apps on andorid 7 nougat. The uri format is content://com.example.myapp

Guaranteed way to find the filepath of the ildasm.exe and ilasm.exe files regardless of .NET version/environment?

若如初见. 提交于 2019-12-03 12:53:18
Is there a way to programmatically get the FileInfo/Path of the ildasm.exe/ilasm.exe executables? I'm attempting to decompile and recompile a dll/exe file appropriately after making some alterations to it (I'm guessing PostSharp does something similar to alter the IL after the compilation). I found a blog post that pointed to: var pfDir = Environment.GetFolderPath(Environment.SpecialFolders.ProgramFiles)); var sdkDir = Path.Combine(pfDir, @"Microsoft SDKs\Windows\v6.0A\bin"); ... However, when I ran this code the directory did not exist (mainly because my SDK version is 7.1), so on my local