Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
GetFullPathName (kernel32)
 
.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern uint GetFullPathName(string lpFileName, uint nBufferLength,
   [Out] StringBuilder lpBuffer, [Out] StringBuilder lpFilePart);

VB.net Signature:

  <DllImport("kernel32.dll")> _
Shared Function GetFullPathName(ByVal lpFileName As String, ByVal nBufferLength As Int32, <Out()> ByVal lpBuffer As System.Text.StringBuilder, <Out()> ByVal lpFilePart As System.Text.StringBuilder) As Int32

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

C# Sample

int bufsz = 1;                            // We'll grow this as necessary
string sRel = @"c:\windows\System\..\system32\desktop.ini";       // Note relative path
StringBuilder sbFull = new StringBuilder(bufsz);          // Full resolved path will go here
StringBuilder sbFile = new StringBuilder(bufsz);          // Filename will go here
uint u = GetFullPathName(sRel, (uint)bufsz, sbFull, out sbFile);  // 1st call: Get necessary bufsz
if (u > bufsz)                            // 'u' should be >1
{
   bufsz = (int)u + 10;                       // Required size plus a few
   sbFull = new StringBuilder(bufsz);                 // Re-create objects w/ proper size
   sbFile = new StringBuilder(bufsz);                 // "
   u = GetFullPathName(sRel, (uint)bufsz, sbFull, out sbFile);    // Try again, this should succeed
   // 'sbFull' should now contain "c:\windows\system32\desktop.ini"
   //    and 'sbFile' should contain "desktop.ini"
}

Alternative Managed API:

System.IO.FileSystemInfo.FullName or System.IO.Path.GetFullPath.

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions