filepath

Function to shrink file path to be more human readable

家住魔仙堡 提交于 2019-11-30 17:13:11
问题 Is there any function in c# to shink a file path ? Input : "c:\users\Windows\Downloaded Program Files\Folder\Inside\example\file.txt" Output : "c:\users\...\example\file.txt" 回答1: Jeff Atwood posted a solution to this on his blog and here it is : [DllImport("shlwapi.dll", CharSet = CharSet.Auto)] static extern bool PathCompactPathEx([Out] StringBuilder pszOut, string szPath, int cchMax, int dwFlags); static string PathShortener(string path, int length) { StringBuilder sb = new StringBuilder()

Hard disk volume path to full file path

倾然丶 夕夏残阳落幕 提交于 2019-11-30 16:08:41
I have an MSVC++ application that spits out the hard disk volume paths of file handles that other applications have open in the following string format: \Device\HarddiskVolume4\Users\User\Documents\Visual Studio 2013\Projects\FileLocker\FileLocker\bin\Debug\Test.txt I would like to convert these paths to full paths to these files in Windows. For example, I would like to convert the above hard disk volume path to a full Windows file path with its corresponding drive letter: C:\Users\User\Documents\Visual Studio 2013\Projects\FileLocker\FileLocker\bin\Debug\Test.txt I have looked online but I

How to get file path of image from URI in Android Lollipop?

不问归期 提交于 2019-11-30 15:51:48
问题 I want to create an image picker for Android Lollipop. I use Intent.ACTION_GET_CONTENT to choose my picture but I cannot get the path of selected image from URI, which the dialog picker returned. I tried codes from these threads: retrieve absolute path when select image from gallery kitkat android https://chintankhetiya.wordpress.com/2013/12/14/picture-selection-from-camera-gallery/ but all of them return null. Can any one help me? 回答1: Try import android.annotation.SuppressLint; import

MSBuild ITaskItem RecursiveDir metadata disappears

六月ゝ 毕业季﹏ 提交于 2019-11-30 15:50:25
问题 I have a custom MSBuild task, which processes a set of files and returns a modified subset of this. Basically, I just create a new ITaskItem array out of the input, skipping some items. However, the RecursiveDir metadata disappears when this result set is returned to MSBuild! It is still with the correct values at the end of my custom task's Execute() method but when I then try to use RecursiveDir in MSBuild, I find that it is empty! This is, of course, quite a problem! What should I do? Is

MSBuild ITaskItem RecursiveDir metadata disappears

一个人想着一个人 提交于 2019-11-30 15:33:37
I have a custom MSBuild task, which processes a set of files and returns a modified subset of this. Basically, I just create a new ITaskItem array out of the input, skipping some items. However, the RecursiveDir metadata disappears when this result set is returned to MSBuild! It is still with the correct values at the end of my custom task's Execute() method but when I then try to use RecursiveDir in MSBuild, I find that it is empty! This is, of course, quite a problem! What should I do? Is this normal? The other metadata such as Filename and Extension is still there. Identity also points to

How to get execution directory of console application

*爱你&永不变心* 提交于 2019-11-30 12:23:13
问题 I tried to get the directory of the console application using the below code, Assembly.GetExecutingAssembly().Location but this one gives me where the assemble resides. This may be different from where I executed the application. My console application parses logs with no parameters. It must go to the logs/ folder inside of the executable's folder or if I give it a path to logs/ it parses it. 回答1: Use Environment.CurrentDirectory . Gets or sets the fully qualified path of the current working

phpunit require_once() error

戏子无情 提交于 2019-11-30 10:21:38
问题 I recently installed phpunit on my server via the pear installer. When I go to run a test I get the following error: PHP Warning: require_once(PHPUnit/Util/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 44 PHP Fatal error: require_once(): Failed opening required 'PHPUnit/Util/Filter.php' (include_path='.:/usr/bin/php') in /usr/bin/phpunit on line 44 After doing some searching, I tried making some modifications to the include_path in my php.ini file

How to handle space of Filename in Batch For Loop

人走茶凉 提交于 2019-11-30 09:42:04
问题 @echo off echo processing please wait... setlocal enabledelayedexpansion set txtfile=%~dp0mysql\my.ini.bak set newfile=%~dp0mysql\my.ini if exist "%newfile%" del /f /q "%newfile%" for /f "tokens=*" %%a in (%txtfile%) do ( set newline=%%a echo !newline! >> %newfile% ) Now my.ini.bak file is in D:\Program Files\my.ini.bak Error : The system cannot find the file Files\mysql\my.ini.bak. How to make this code work, so it copy each line from my.ini.bak to my.ini 回答1: I don't think you need to quote

File path for AJAX script (in Wordpress)

馋奶兔 提交于 2019-11-30 08:17:39
问题 I use this jquery-ajax script to send email: $.ajax({ url: process.php, type: "POST", data: data, cache: false, ... in url I call the php file that sends email, but ajax get it only if I specify the full path: url: "http://www.domain.com/wp-content/themes/site_theme/templates/process.php", but I have to use a syntax like this: url: "../../templates/process.php", or using a variable to declare in the html header/footer Html <script type="text/javascript"> var urlMail = '<?php bloginfo(

Visual Studio - Unit tests loading resources in the project

让人想犯罪 __ 提交于 2019-11-30 08:06:21
The goal is to run some tests given some data in those Xml files. How would you easily load a given Xml file into an XmlDoc within the unit test methods? Current state is: XmlDocument doc = new XmlDocument(); string xmlFile = "4.xml"; string dir = System.IO.Directory.GetCurrentDirectory() + @"\Msgs\" //dir is then the value of the current exe's path, which is //d:\sourcecode\myproject\TestResults\myComputer 2009-10-08 16_07_45\Out //we actually need: //d:\sourcecode\myproject\Msgs\ doc.Load( dir + fileName); //should really use System.IO.Path.Combine()! Is it just a simple matter of putting