VB.Net code to read a text file from a USB with unspecified drive letter?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

VB.Net code to read a text file from a USB with unspecified drive letter?

I already have a code for detecting a removable device. However, I would like to enable my program to detect that USB drive and read and print the text in that specific text file on my webpage. I also have a program code for reading and printing a text file from a USB but that program needs the drive letter to be specified. My problem is, how would I program if the drive letter is unspecified? Here is my code by the way,

Code:

<%@ Import NameSpace="System.IO" %>
<%
For Each d As System.IO.DriveInfo In My.Computer.FileSystem.Drives
If d.DriveType = DriveType.Removable Then
Dim test As String = File.ReadAllText(& ":\\sample.txt")
Response.Write(test)
End If
Next
%>

My problem now is how to let the string test get the data so that I could put it on my page. I'm currently using that File.ReadAllText method but I'm open to suggestions if there would be any.

Re: VB.Net code to read a text file from a USB with unspecified drive letter?

In order to read a file then either the drive where the file is at must be the current drive or you must specify the drive letter. In general if it is not the drive you program is being ran from then you would need code to switch to that drive or specify the drive letter with the file name.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.