473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PathTooLongException

hi ,
i try to

io.file.delete(startmenushortcut)
i get PathTooLongException

how to delete those dead links in my start menu
please
Oct 10 '08 #1
5 3344
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
Oct 10 '08 #2
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
Oct 10 '08 #3
On Oct 10, 10:18*pm, "Gillard" <gillard_georges@@@@@@@@@hotmail.com>
wrote:
thank you kimi but I *know that

my problem is to delete the files that have a too long path

"kimiraikkonen" <kimiraikkone...@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- Hide quoted text -

- Show quoted text -
Well, are you able to reduce file name by renaming with
"My.Computer.Filesystem.RenameFile"? Then try to delete.

If renaming file to a smaller name does not help, try also renaming
directories along that path to fit the whole path in 250 char scale.

Hope this helps,

Onur Güzel
Oct 10 '08 #4
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
Oct 10 '08 #5
thank you very much Tom
that's all right now
"Tom Shelton" <to*********@comcastXXXXXXX.netwrote in message
news:cJ******************************@comcast.com. ..
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**********************************@d70g200 0hsc.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
Oct 11 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: PG | last post by:
I am reading a directory using FileInfo Class. Have an exception "PathTooLongException" error and would like to catch the name of the file and its path that is throwing the exception. Thanks a lot...
0
by: Shakil Khan | last post by:
System.IO.PathTooLongException "The path is too long after being fully qualified. Make sure path is less than 260 characters" Can anyone help, How to resolve this issue? This exception is...
2
by: Justin | last post by:
Hi. I'm writing a little c# program to list all the files in a selected directory longer than a given size. The problem is that when it finds a file that is too long for Windows, I get the...
5
by: | last post by:
Hello Guys, I am trying to render an Xml dataset into HTML using XSLT. When I am loading the XSLT file into transform object to render it. Here is the code snippet: <!-- XslTransform...
6
by: I am Sam | last post by:
I keep getting this error and I don't know why: The path is too long after being fully qualified. Make sure path is less than 260 characters. Description: An unhandled exception occurred...
6
by: shrishjain | last post by:
Hi All, I call Assembly.LoadFrom("C:\\MyDir\\MyAssembly.dll")- it works fine. However when I call the following, it fails: ...
0
by: Johan Delimon | last post by:
Hello, Ever got this error? The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248...
0
by: mjheitland | last post by:
When I pass my directories recursively on a directory structure with paths 260 chars I get the following exception (see line marked with ***), although I am using only ShortPathNames through...
0
by: Michael Heitland | last post by:
To traverse folders recursively that contain files with a path 260 chars we can use Unicode versions of FindFirst and FindNext and prefix all paths with NTFS escape sequence '\\?\'. Files can be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.