Hi Eric,
If your files have to be read from CD-ROM drive then you can
search for those in this way:
public string GetDocXmlFilePa th(string relatedPath) {
string[] drivesPathTab=D irectory.GetLog icalDrives();
for(int i=0; i<drivesPathTab .Length; i++) {
DirectoryInfo dirInfo=new DirectoryInfo(d rivesPathTab[i]);
if( (dirInfo.Attrib utes & FileAttributes. ReadOnly)!=0 ) {
// this drive is read only so...
// if you know related path you can acces your file
// after checking if it exists on this drive...
string fullPath=Path.C ombine(drivesPa thTab[i], relatedPath);
if( File.Exist( fullPath) ) {
return fullPath;
}
}
return String.Empty;
}
Aboved sample should be working, but it is not a "State Of The Art"... (o:
Those sample should help you find a way to minimize searching for wanted CD-ROM
drive... e.g. if path is returned then keed it in variable since file
wasn't found in a path, then search again...
And to avoid of reading floppies (it doesn't "sounds" good).
Marcin Grzębski
Eric wrote:
I have an application which today loads some XML files onto the hard
drive. We have been acked to change the application to instead keep
the data files on the
CD. I have fixed the install, but now am trying to fix the C# code to
look at the CD instead of the folder on the Hard drive.
Here is the code that exists now.
public String GetApplicationF older()
{
String sPath = Application.Exe cutablePath;
return(sPath.Su bstring(0,sPath .LastIndexOf("\ \")) + "\\");
}
I need it to look at the CD instead of the ExecutablePath. Any help
would be greatly appreciated.
Thanks,
Eric Swaney