title: How to handle very long file names (with TPath)?
body: <p>I have a program that downloads some files from Internet. The file name could be very long (100 chars).
  The user may choose to save these these files in a folder that has a very long name (200 chars).
  So, the total length of the path is over <a href="https://support.microsoft.com/en-us/kb/2891362" rel="nofollow">260 chars</a>.</p>
  
  <p>I tried to create a function that checks if the path is too long and truncates the filename so the whole path will be exactly 260 chars. But functions in TPath class fails to work if the path is over 260 chars. More exactly GetDirectoryName raises a specific error when the path is over 260 chars, so I cannot use it to split the folder from file name. </p>
  
  <p><strong>A major design flaw in Delphi?</strong><br>
  I think that TPath raising an error when working on long file names is a big flaw. Simply using GetDirectoryName to READ (not to write) will simply crash your program. TPath should allow processing long paths. MAYBE it should raise the error ONLY when you try to WRITE files with long path. But not even then. NTFS accepts long paths. So, why Delphi should force you to stick to 260? Some programs can handle longs paths. For example, I use Total Commander (never Explorer) so I am not affected by the long file name issue.</p>
  
  <p>Any idea on how to treat this case?<br>
  Note: The download process is automated so I won't stop to ask the user to enter a new file name for each file that fails to be under 260 chars. I want to handle this silently.</p>