filepath

Java: Get URI from FilePath

。_饼干妹妹 提交于 2019-11-26 16:58:59
问题 I've little knowledge of Java. I need to construct a string representation of an URI from FilePath(String) on windows. Sometimes the inputFilePath I get is: file:/C:/a.txt and sometimes it is: C:/a.txt . Right now, what I'm doing is: new File(inputFilePath).toURI().toURL().toExternalForm() The above works fine for paths, which are not prefixed with file:/ , but for paths prefixed with file:/ , the . toURI method is converting it to a invalid URI, by appending value of current dir, and hence

Java JTree directory structure from file paths

与世无争的帅哥 提交于 2019-11-26 16:44:14
I've been trying to get my head around this so maybe some of you can help me. I have a list of files with their full paths (these are just strings the files are on another machine), e.g: C:\a\b\c\file1.txt C:\a\b\c\file2.txt C:\a\d\file3.txt C:\e\file4.txt I want to create a Jtree to show the directory structure like this: C: a b c file1.txt file2.txt d file3.tct e file4.txt I've been spliting the string on the seperator so I end up with a list of arrays like: "C:","a","b","c","file1.txt" "C:","a","b","c","file2.txt" "C:","a","d","file3.txt" "C:","e","file4.txt" Now I want to add them an index

Efficiently convert backslash to forward slash in R

柔情痞子 提交于 2019-11-26 16:03:58
I am looking for an efficient way to convert back slash to forward slash in R. Sometime I copy the link of the directory from the windows and I get something like this: C:\Users\jd\Documents\folder\file.txt How can I quickly change this to C:/Users/jd/Documents/folder/file.txt ? I cannot even read the above expression as character. It throws an error "\u used without hex digits in character string starting ""C:\u". I know TAB function in R helps to find the location fast, but was just wondering if there was any other work around. I could change the working directory to the location of folder

accessing a file using [NSBundle mainBundle] pathForResource: ofType:inDirectory:

老子叫甜甜 提交于 2019-11-26 15:18:29
问题 I have a file paylines.txt added inside the folder named TextFiles which resides inside the Resources folder of my iOS project in Xcode. This is the code I use to access the file: NSString* filePath = [[NSBundle mainBundle] pathForResource:@"paylines" ofType:@"txt" inDirectory:@"TextFiles"]; NSLog(@"\n\nthe string %@",filePath); The code prints: 2011-06-07 14:47:16.251 slots2[708:207] the string (null) 回答1: I was also having the same problem. The Solution i found is ( in xcode 4.x): Go to :

How can I obtain the case-sensitive path on Windows?

一笑奈何 提交于 2019-11-26 14:36:50
问题 I need to know which is the real path of a given path. For example: The real path is: d:\src\File.txt And the user give me: D:\src\file.txt I need as a result: d:\src\File.txt 回答1: You can use this function: [DllImport("kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)] static extern uint GetLongPathName(string ShortPath, StringBuilder sb, int buffer); [DllImport("kernel32.dll")] static extern uint GetShortPathName(string longpath, StringBuilder sb, int buffer); protected static string

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

限于喜欢 提交于 2019-11-26 14:09:27
问题 Hi I have this little command to copy files in a batch, which will help because I do this specific copy multiple times a day. The problem occurs while using the xcopy command. Everything is in order, but I am receiving this error: "Invalid path 0 files copied". Here is the code: C:\Windows\System32\xcopy /Y "C:\Users\Ryan\Desktop\mmars_pub\" "C:\Users\Ryan\Desktop\Dropbox\MMARS\mmars_pub\" I'm using the full path to the xcopy executable because I was having trouble configuring the path

Convert content:// URI to actual path in Android 4.4

别来无恙 提交于 2019-11-26 12:54:14
I tried a solution (see below) that works fine, except in Android 4.4 the call to startActivityForResult() brings up an activity titled "Open from", which has "Recent", "Images", "Downloads" as well as several apps to pick from. When I choose "Images" and try to resolve the returned content URI (using the code below), the call to cursor.getString() returns null. If I choose the exact same file using the Gallery app, cursor.getString() returns a file path. I've only tested this in API levels 16 and 19. Everything works as expected in 16. As far as 19 goes, I have to choose the Gallery or other

VBScript to open a dialog to select a filepath

时光毁灭记忆、已成空白 提交于 2019-11-26 11:26:56
问题 At present I am opening a file with my vbscript as follows: strFile = \"C:\\Users\\test\\file.txt\" Set objFile = objFSO.OpenTextFile(strFile) I would like to change this so that a file can be selected/navigated to by the user and that file is used in the script. How can I add this ability? I have tried to search for how to load a file dialog/prompt the user for a file etc just not sure how to complete in a VBScript. 回答1: There is another solution I found interesting from MS TechNet less

Why use os.path.join over string concatenation?

╄→гoц情女王★ 提交于 2019-11-26 10:38:46
问题 I\'m not able to see the bigger picture here I think; but basically I have no idea why you would use os.path.join instead of just normal string concatenation? I have mainly used VBScript so I don\'t understand the point of this function. 回答1: 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.

What does \\?\ mean when prepended to a file path

不羁的心 提交于 2019-11-26 10:31:27
问题 I found a reference to a file in a log that had the following format: \\\\?\\C:\\Path\\path\\file.log I cannot find a reference to what the sequence of \\?\\ means. I believe the part between the backslashes refers to a hostname. For instance, on my Windows computer, the following works just fine: dir \\\\?\\C:\\ and also, just fine with same result: dir \\\\.\\C:\\ Questions: Is there a reference to what the question mark means in this particular path format? What might generate a file path