filepath

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

岁酱吖の 提交于 2019-12-03 03:32:49
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 this by using this code: public game(){ String testPath = this.getClass().getClassLoader().getResource("")

Map the physical file path in asp.net mvc

好久不见. 提交于 2019-12-02 20:02:37
I am trying to read an XSLT file from disk in my ASP.Net MVC controller. What I am doing is the following: string filepath = HttpContext.Request.PhysicalApplicationPath; filepath += "/Content/Xsl/pubmed.xslt"; string xsl = System.IO.File.ReadAllText(filepath); However, half way down this thread on forums.asp.net there is the following quote HttpContext.Current is evil and if you use it anywhere in your mvc app you are doing something wrong because you do not need it. Whilst I am not using Current , I am wondering what is the best way to determine the absolute physical path of a file in MVC?

Find the path of notepad.exe and mspaint.exe

霸气de小男生 提交于 2019-12-02 17:32:47
What is the best way to find out where notepad.exe and mspaint.exe are that will work across various versions of Windows? Should I get the Windows directory via SHGetFolderPath(NULL, CSIDL_WINDOWS, NULL, SHGFP_TYPE_CURRENT, dir) , and then traverse through all the subdirectories to look for the two files? (Assume that I am not interested in anything outside the Windows folder.) This works on every Windows box I've got access to (XP+). c:\> for %i in (cmd.exe) do @echo %~$PATH:i C:\WINDOWS\system32\cmd.exe c:\> for %i in (python.exe) do @echo %~$PATH:i C:\Python25\python.exe The great thing is,

“@/path/to/a/file” in PHP, what does it mean?

不打扰是莪最后的温柔 提交于 2019-12-02 16:46:37
问题 I have stumbled to following code example: $image = 'file/path'; $code = $tmhOAuth->request('POST', 'https://upload.twitter.com/1/statuses/update_with_media.json', array( 'media[]' => "@{$image}", 'status' => "Don't slip up" // Don't give up.. ), true, // use auth true // multipart ); The confusing bit is "@{$image}", what that "at" sign does in front of the file path? Thanks! 回答1: I don't know what library you're using, but I assume it uses the PHP cURL extension internally, because that's

Combine path, file strings and literals for path

谁都会走 提交于 2019-12-02 16:18:25
问题 Trying to combine a path, filename, and add some text along with a variable for Out-File log. I've tried many alternatives unsuccessfully and need assistance; FormattedDate = Get-Date -Format "yyyy-MM-dd HH:mm:ss" $OldVersion = C:\Temp\TestFile.txt $OldPath = (Get-Item $OldVersion).DirectoryName $OldBaseName = (Get-Item $OldVersion).BaseName ErrFile = Join-Path $OldPath OldBaseName Out-File -FilePath "$ErrFile_$FormattedDate Error.txt" Out-File -FilePath "$($OldPath)$($OldBaseName)_$(

“@/path/to/a/file” in PHP, what does it mean?

给你一囗甜甜゛ 提交于 2019-12-02 07:55:56
I have stumbled to following code example: $image = 'file/path'; $code = $tmhOAuth->request('POST', 'https://upload.twitter.com/1/statuses/update_with_media.json', array( 'media[]' => "@{$image}", 'status' => "Don't slip up" // Don't give up.. ), true, // use auth true // multipart ); The confusing bit is "@{$image}", what that "at" sign does in front of the file path? Thanks! I don't know what library you're using, but I assume it uses the PHP cURL extension internally, because that's how you specify to cURL the path to a file that you want to upload, i.e., by prepending the path with an @ .

The open() functions doesn't behave correctly with filepath containing special characters

有些话、适合烂在心里 提交于 2019-12-02 02:15:43
问题 I'm writing this simple code: file = input('File to read: ') fhand = open(file, 'r') The file I want to open is called 'test.txt', and it is located in a subfolder; what I put into the requested input therefore is: 'DB\test.txt'. Well: it doesn't work, returning this error message: OSError: [Errno 22]Invalid argument: 'DB\test.txt'. I have another file in the same directory, called 'my_file.txt', and I don't get errors attempting to open it. Lastly I have another file, called 'new_file.txt',

How do I get the absolute path of DocumentsLibrary in Win8/Metro/WinRT?

拟墨画扇 提交于 2019-12-02 00:55:13
问题 I have my manifestappx file setup to have access to Documents Library Access and a file association, but when I call Windows::Storage::KnownFolders::DocumentsLibrary->Path Path returns a blank string. How do I get the path to return properly? Thanks in advance for the help 回答1: Because DocumentsLibrary is a virtual location representing a collection of different locations and files, it will not have a path: Libraries, a concept introduced in Windows 7, allow users to view related user content

Problem with spaces in a filepath - commandline execution in C#

落花浮王杯 提交于 2019-12-01 22:55:38
问题 I am building a gui for a commandline program. In txtBoxUrls[TextBox] file paths are entered line by line. If the file path contains spaces the program is not working properly. The program is given below. string[] urls = txtBoxUrls.Text.ToString().Split(new char[] { '\n', '\r' }); string s1; string text; foreach (string s in urls) { if (s.Contains(" ")) { s1 = @"""" + s + @""""; text += s1 + " "; } else { text += s + " "; } } System.Diagnostics.Process proc = new System.Diagnostics.Process();

C# relative path not start from working directory

自作多情 提交于 2019-12-01 22:45:46
问题 I have a C# program, it will read a file from a relative path ./report/report1.rdlc , however sometime for a unknown reason it found the file from a completely different place C:\Windows\system32\report\report1.rdlc but the file actually is place in C:\Program Files (x86)\Application1\report\report1.rdlc and the program is inside C:\Program Files (x86)\Application1\ . Any reason the relative path not start from working directory? 回答1: It does start from the working directory. However, you