During data backup and recovery today, I encountered a space problem in the path, so I had to seek help from API, search, getmediapathname (), and query MSDN. The speed was too slow. Forget it, PInvoke is a knowledge base that focuses on APIs. However, it was unexpectedly discovered that PInvoke.net has implemented a VS-based plug-in. It is very nice to try it out and cannot be exclusive, I recommend it to you ......
Install PInvokeVsAddin, restart VS, and add PInvoke.net to the menu. OK
Open the project and Insert PInvoke signatures...
Search...
If you are not familiar with the use of APIS, PInvoke provides the help of the website example, "Go to funcation in PInvoke.net", the link is already provided on the plug-in, for example: the getmediapathname plugin automatically navigate to an instance of http://pinvoke.net/default.aspx/kernel32.GetShortPathName, VB, C #, Other.
A simple example:
Code
// Http://cnblogs.com/winzheng
Class Program
{
[DllImport ("kernel32.dll", CharSet = CharSet. Auto, SetLastError = true)]
Static extern uint get1_pathname (
[Financialas (UnmanagedType. LPTStr)]
String lpszLongPath,
[Financialas (UnmanagedType. LPTStr)]
StringBuilder lpszShortPath,
Uint cchBuffer );
Static void Main ()
{
Console. WriteLine (getmediapathname (Environment. CurrentDirectory ));
Console. ReadLine ();
}
/// <Summary>
///
/// </Summary>
/// <Param name = "longName"> The long name path </param>
/// <Returns> A short name path string </returns>
Public static string getdomainpathname (string longName)
{
StringBuilder shortNameBuffer = new StringBuilder (256 );
Uint bufferSize = (uint) shortNameBuffer. Capacity;
Uint result = getmediapathname (longName, shortNameBuffer, bufferSize );
If (result! = 0)
Return shortNameBuffer. ToString ();
Return longName;
}
A function that changes the path to the 8.3 format is completed at the moment of motion, is it worth promoting? However, the tool is not just to speed up our development, try not to spend time writing repetitive code. You need to think carefully about unfamiliar technologies to avoid leaving the tool. We will not write anything ....
Strongly recommended... example source code