Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looking for a reliable way to determine if a drive letter is in use
#3
(05-08-2023, 03:46 PM)hanness Wrote: I'm looking for a reliable way to determine if a drive letter is in use but I'm running into some difficulties.

Take the following small clip as an example:

A$ = "F:\"
If _DirExists(A$) Then
    Print A$; " Exists"
Else
    Print A$; "Does not exist"
End If

Normally, this works fine and indicates if the drive letter contained in A$ exists. But now consider these two exceptions:

1) Suppose I have a thumbdrive attached to the system that has been wiped clean. By wiped clean, I mean you open DISKPART, select the thumbdrive, and perform a "CLEAN" on that drive. In this instance, there will be no partitions on the drive, but in File Explorer, the drive still shows up with a drive letter. However, the clip above will indicate that this drive letter does NOT exist. As a result, if I try to assign that drive letter to another drive, it will fail because it is already in use.

2) The same thing happens if I connect a drive that has BitLocker encryption but has not yet been unlocked. The QB64PE code will indicate that the drive letter does not exist even though it is already in use.

Any suggestions on a better way to determine if a drive letter is in use?

Just off the top of my head perhaps:

A$ = "F:\."

The period added will force a root directory check maybe?
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Looking for a reliable way to determine if a drive letter is in use - by TerryRitchie - 05-08-2023, 03:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What the heck, it's Friday let's drive some people nuts. doppler 4 1,030 10-21-2024, 11:31 AM
Last Post: SpriggsySpriggs
  _File$ is not behaving as expected, cannot determine why hanness 6 1,681 10-14-2024, 01:56 AM
Last Post: a740g
Sad Is there a way to determine screen resolution ? doppler 2 735 08-03-2023, 02:30 PM
Last Post: doppler
  Is it possible to determine the screen scaling factor within QB64? hanness 3 851 05-09-2022, 01:37 AM
Last Post: hanness

Forum Jump:


Users browsing this thread: