June 18th, 2012, 02:42 AM
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,
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.
<%@ 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")
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!