4

I'm working on a utility which has an input for a shared folder. My app requires that the folder selected is on a remote computer, and not on the local computer. I would like to recognize if the user selects C:\ from the local computer as opposed to Z:\ which is probably a network drive. How do I validate this?

Jerry Dodge
  • 26,858
  • 31
  • 155
  • 327
  • 1
    See [Serg's answer](http://stackoverflow.com/a/10458991/576719) to the question [Delphi - Comparing two pathnames when one is UNC and one is drive letter-specified](http://stackoverflow.com/q/10458753/576719). [ExpandUNCFileName](http://docwiki.embarcadero.com/Libraries/en/System.SysUtils.ExpandUNCFileName). This function returns network drives starting with \\ – LU RD Jul 22 '12 at 19:30
  • Good trick, I've summed it up to `IsNetworkPath := Pos('\\', ExpandUNCFileName(APath)) = 1;` – Jerry Dodge Jul 22 '12 at 19:36
  • 1
    Its should be noted that GetDriveType will return DRIVE_REMOTE, and ExpandUncFileName will return a result starting with '\\' for a drive created with SUBST on the local computer. – David Dubois Jul 24 '12 at 10:56

1 Answers1

6

The function you need is GetDriveType.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490