On 2008-10-10, Gillard <gillard_georges@wrote:
thank you kimi but I know that
my problem is to delete the files that have a too long path
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:82**********************************@d70g2000 hsc.googlegroups.com...
>On Oct 10, 2:51 pm, "Gillard" <gillard_georges@@@@@@@@@hotmail.com>
wrote:
>>hi ,
i try to
io.file.delete(startmenushortcut)
i get PathTooLongException
how to delete those dead links in my start menu
please
Look at Maximum Path Lenght section:
http://msdn.microsoft.com/en-us/library/aa365247.aspx
It appears that the full path of your file exceeds 260 chars at first
sight.
Onur Güzel
If that's the case, then in this situation you'll have to resort to using
P/Invoke and the DeleteFile api. You can not delete a file with the .NET
functions that exceeds MAX_PATH - which is defined as 260 characters, even
though NTFS supports paths as long as 32k characters.
Here is the declare for the DeleteFile api:
Declare Auto Function DeleteFile Lib "kernel32" ( _
ByVal lpFilePath As String) As Boolean
Now, simply declaring and using this API won't work either - because the file
api's also by default enforce the traditional MAX_PATH value. So, to actually
get the function to delete a long path, you have to pre-append the value
"\\?\" to the path.
For example:
Dim p As String = "\\?\C:\Test\SomeFile.Txt"
If Not DeleteFile (p) Then
Throw New System.ComponentModel.Win32Exception(Marshal.GetLa stWin32Error())
End If
If you want a lot more information on this, just google MAX_PATH and .NET :)
--
Tom Shelton