filepath

Drive letter from URI type file path in C#

∥☆過路亽.° 提交于 2019-12-21 08:18:04
问题 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? 回答1: var uri = new Uri("file:///D:/Directory/File.txt"); if (uri.IsFile) { DriveInfo di = new DriveInfo(uri.LocalPath); var driveName = di

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

六月ゝ 毕业季﹏ 提交于 2019-12-21 03:58:26
问题 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,

What file path would I use with ng-include?

点点圈 提交于 2019-12-21 03:46:18
问题 My angular project's path is like this web server.py ##flask server program app static app.js controllers.js etc... templates index.html home.html index.html <!-- this didn't work --> <ng-include src="templates/home.html"><ng-include> <!-- nor did this --> <ng-include src="home.html"></ng-include> home.html <h1> home! </h1> Except I don't see the partial (home.html) in my output. Anyone see my mistake? 回答1: The src attribute of ng-include expects a string. Either you pass a scope variable, or

Get file size without using System.IO.FileInfo?

三世轮回 提交于 2019-12-21 03:40:53
问题 Is it possible to get the size of a file in C# without using System.IO.FileInfo at all? I know that you can get other things like Name and Extension by using Path.GetFileName(yourFilePath) and Path.GetExtension(yourFilePath) respectively, but apparently not file size? Is there another way I can get file size without using System.IO.FileInfo ? The only reason for this is that, if I'm correct, FileInfo grabs more info than I really need, therefore it takes longer to gather all those FileInfo's

IllegalArgumentException: Failed to find configuration root that contains xxx on FileProvider.getUriForFile

风格不统一 提交于 2019-12-21 03:26:04
问题 I have been trying to follow the Android tutorial on sharing files. I set up the FileProvider like this: On the main manifest xml: <provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.mysecondapp.fileprovider" android:exported="false" android:grantUriPermissions="true" > <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" /> </provider> the res/xml/filpaths.xml file: <paths xmlns:android="http://schemas

get path from Google Drive URI

眉间皱痕 提交于 2019-12-20 21:06:23
问题 I'm using Android file selection and selecting files from app storage (images, videos, documents). I have an function "getPath" . Im getting path from uri. I have no problem with gallery images or download documents. But when i select a file from google drive i cant get path. This is the google drive uri "content://com.google.android.apps.docs.storage/document/acc%3D25%3Bdoc%3D12" Can you help me about it ? This is also my "getPath" function. public static String getPath(final Context context

File paths in Python in the form of string throw errors

孤街醉人 提交于 2019-12-19 17:37:36
问题 I need to put a lot of filepaths in the form of strings in Python as part of my program. For example one of my directories is D:\ful_automate\dl . But Python recognizes some of the characters together as other characters and throws an error. In the example the error is IOError: [Errno 22] invalid mode ('wb') or filename: 'D:\x0cul_automate\\dl . It happens a lot for me and every time I need to change the directory name to one that may not be problematic. 回答1: The \ character is used to form

Read file from a folder inside the project directory

杀马特。学长 韩版系。学妹 提交于 2019-12-19 10:15:59
问题 In a JSP project I am reading a file from directory. If i give the full path then i can easily read the file BufferedReader br = new BufferedReader(new FileReader("C:\\ProjectFolderName\\files\\BB.key")); but i don't want to write the full path instead i just want to give the folder name which contains the file, like bellow. BufferedReader br = new BufferedReader(new FileReader("\\files\\BB.key")); How to do this? String currentDirectory = new File("").getAbsolutePath(); System.out.println

Specifying a relative path

我怕爱的太早我们不能终老 提交于 2019-12-19 07:59:08
问题 I have a windows forms project. In the current directory I have a Help folder with *.chm files. What is the easiest way to launch them from the application? How can I specify the relative path to them? 回答1: You should use Help.ShowHelp to do this var chmFile = "CHM/test.chm"; Help.ShowHelp(ctrl, chmFile); by default ShowHelp will search file in the application path 回答2: The Environment.CurrentDirectory property will be set to the location of your .exe file. So if you place your help folder in

C# Filepath Recasing

≡放荡痞女 提交于 2019-12-18 11:45:18
问题 I'm trying to write a static member function in C# or find one in the .NET Framework that will re-case a file path to what the filesystem specifies. Example: string filepath = @"C:\temp.txt"; filepath = FileUtility.RecaseFilepath(filepath); // filepath = C:\Temp.TXT // Where the real fully qualified filepath in the NTFS volume is C:\Temp.TXT I've tried the following code below and many variants of it and it still doesn't work. I know Windows is case-insensitive in general but I need to pass