[DllImport("kernel32.dll")]
static extern uint GetFullPathName(string lpFileName, uint nBufferLength,
[Out] StringBuilder lpBuffer, out StringBuilder lpFilePart);
<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
None.
None.
Please add some!
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"
}
System.IO.FileSystemInfo.FullName or System.IO.Path.GetFullPath.