-1

I use the Directory.getLastWriteTimeUtc() method. If the path is too long for this method it throws an PathTooLongException. So I started to use Google finding a solution for this problem. A couple of search results adviced me to use \\?\ as a prefix. Using the Windows Explorer this solution works perfectly. But it does not work with Visual Basic. Adding this prefix to the path the result is an ArgumentException because the is an illegal character in the path.

So I want to ask you if you have a solution to handle long paths with Visual Basic.

The snippet of code that causes the problem is the following one. It is used to get the most recent file of a folder.

Oh, I'm sorry. Of course I will show you my snippet of code that causes the problem.

Try
If Directory.GetLastWriteTimeUtc(s) > Directory.GetLastWriteTimeUtc(latest) Then
latest = s
End If
Catch e As PathTooLongException
 Console.WriteLine("error...")
End Try
Kazimierz Jawor
  • 18,861
  • 7
  • 35
  • 55
jp_
  • 228
  • 2
  • 8
  • 2
    presenting your code will improve possibility to get support here. We can usually check if there is similar problem on our computers to give you any answer or help. So?! – Kazimierz Jawor Aug 22 '13 at 06:30
  • Oh I am sorry. I added my code to my initial post above. – jp_ Aug 26 '13 at 13:42

1 Answers1

0

I solved the problem by subsitute the Delimon.Win32.IO for the System.IO library. Now I can handle such long paths. Hope I can help anyone later.

jp_
  • 228
  • 2
  • 8