filepath

Document directory path change when rebuild application

若如初见. 提交于 2019-11-28 11:10:39
I download the video file from url and save it in document directory with this path: let destination: DownloadRequest.DownloadFileDestination = { _, _ in let pathComponent = "pack\(self.packID)-\(selectRow + 1).mp4" let directoryURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let folderPath: URL = directoryURL.appendingPathComponent("Downloads", isDirectory: true) let fileURL: URL = folderPath.appendingPathComponent(pathComponent) return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) } my video is downloaded and plays successfully. but

Full path with double backslash (C#)

为君一笑 提交于 2019-11-28 10:08:19
Is it possible to get a full path with double backslash by using Path.GetFullPath ? Something like this: C:\\Users\\Mammamia\\Videos\\Documents\\CFD\\geo_msh\\cubeOp.txt instead of this: C:\Users\Mammamia\Videos\Documents\CFD\geo_msh\cubeOp.txt Or is there any other method? Do you mean this? Path.GetFullPath(path).Replace(@"\", @"\\"); C:\\Users\\Mammamia\\Videos\\Documents\\CFD\\geo_msh\\cubeOp.txt is not a valid path, so I'm not sure why you'd want it, but: Path.GetFullPath(yourPath).Replace("\\", "\\\\"); You can just do this: Path.GetFullPath(@"C:\\Users\\Mammamia\\Videos\\Documents\\CFD\

git checkout error: unable to create file

我怕爱的太早我们不能终老 提交于 2019-11-28 09:04:11
While cloning a git repository from Linux to a Windows system, I am getting the following error in checkout the phase: $ git clone gituser@serveraddr:/git/git_repo.git git_WA Cloning into 'git_WA'... gituser@serveraddr's password: remote: Counting objects: 500846, done. remote: Compressing objects: 100% (118676/118676), done. remote: Total 500846 (delta 307739), reused 483023 (delta 291136) Receiving objects: 100% (500846/500846), 907.54 MiB | 9.04 MiB/s, done. Resolving deltas: 100% (307739/307739), done. error: unable to create file RealR******************************************************

How to get the path of app(without app.exe)?

爱⌒轻易说出口 提交于 2019-11-28 08:43:02
I want to get the path of my app like: "\\ProgramFiles\\myApp", I try to use the following code: string path = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; But it returns a path which has "\\myapp.exe" at the end. I also tried: string path = System.IO.Directory.GetCurrentDirectory(); But it throws an “NotSupportedException”. Is there any way to get a path without .exe at the end? Dan Byström path = System.IO.Path.GetDirectoryName( path ); Application.StartupPath should do that for you. Update: from you edit I see that you are running on Compact Framework. Then

How to build a full path string (safely) from separate strings?

独自空忆成欢 提交于 2019-11-28 06:39:49
Does C++ have any equivalent to python's function os.path.join ? Basically, I'm looking for something that combines two (or more) parts of a file path so that you don't have to worry about making sure the two parts fit together perfectly. If it's in Qt, that would be cool too. Basically I spent an hour debugging some code and at least part of it was because root + filename had to be root/ + filename , and I'm looking to avoid that in the future. Stephen Chu Check out QDir for that: QString path = QDir(dirPath).filePath(fileName); Only as part of Boost.Filesystem library. Here is an example:

Get the (last part of) current directory name in C#

时光怂恿深爱的人放手 提交于 2019-11-28 06:39:33
I need to get the last part of current directory, for example from /Users/smcho/filegen_from_directory/AIRPassthrough , I need to get AIRPassthrough . With python, I can get it with this code. import os.path path = "/Users/smcho/filegen_from_directory/AIRPassthrough" print os.path.split(path)[-1] Or print os.path.basename(path) How can I do the same thing with C#? ADDED With the help from the answerers, I found what I needed. using System.Linq; string fullPath = Path.GetFullPath(fullPath).TrimEnd(Path.DirectorySeparatorChar); string projectName = fullPath.Split(Path.DirectorySeparatorChar)

How to get the file path from URI? [duplicate]

为君一笑 提交于 2019-11-28 06:13:33
This question already has an answer here: Get filename and path from URI from mediastore 24 answers Please find my code below. I need to get the file path of the pdf document, selected by the user from SDcard. The issue is that the URI.getPath() returns: /file:///mnt/sdcard/my%20Report.pdf/my Report.pdf The correct path is : /sdcard/my Report.pdf Please note that i searched on stackoverflow but found the example of getting the filePath of image or video, there is no example of how to get the filepath in case of PDF ? My code , NOT all the code but only the pdf part : public void openPDF(View v

Directory.GetFiles: how to get only filename, not full path? [duplicate]

北战南征 提交于 2019-11-28 06:08:19
Possible Duplicate: How to get only filenames within a directory using c#? Using C#, I want to get the list of files in a folder. My goal: ["file1.txt", "file2.txt"] So I wrote this: string[] files = Directory.GetFiles(dir); Unfortunately, I get this output: ["C:\\dir\\file1.txt", "C:\\dir\\file2.txt"] I could strip the unwanted "C:\dir\" part afterward, but is there a more elegant solution? You can use System.IO.Path.GetFileName to do this. E.g., string[] files = Directory.GetFiles(dir); foreach(string file in files) Console.WriteLine(Path.GetFileName(file)); While you could use FileInfo , it

Two asterisks in file path

帅比萌擦擦* 提交于 2019-11-28 04:03:57
What does the following file path mean? $(Services_Jobs_Drop_Path)\**\*.config The variable just holds some path, nothing interesting. I'm a lot more concerned, what the hell the ** mean. Any ideas? P.S. The following path is used in msbuild scripts, if it helps. sll \**\ This pattern is often used in Copy Task for recursive folder tree traversal. Basically it means that all files with extension config would be processed from the all subdirectories of $(Services_Jobs_Drop_Path) path. MSDN, Using Wildcards to Specify Items : You can use the **, *, and ? wildcard characters to specify a group of

Ant produces jsfl with backslashes instead of slashes

◇◆丶佛笑我妖孽 提交于 2019-11-28 03:38:29
问题 I'm using Ant with FDT 3 and I have Ant creating a jsfl to compile fla's. When I use the built in '${basedir}' property in Ant it gives me the path with backslashes( \ ) in it because I'm on Windows. The problem is that when its run through jsfl the slashes are taken as escapes. I need to know how to modify the basedir property so the slashes are converted to forward slashes. I've tried splitting the basedir on backslashes in jsfl and joining it with forward slashes as a delimiter, but the