GetFiles problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hi guys

i wanna list the files of a user-chosen directory using getfiles(path)...
path is in this case SearchFilesDialog.SelectedPath.ToString()... but that
causes an exception tellin me that the 2nd pathfragment mustnt be a drive
letter or unc-name... i cannot figure it out and i haven't found a
description of this exception in the .net-documentation 1.1...

thx for your help
 
Rakesh Rajan said:
Hi,

Could you post your code please?...this would give a better idea...

- Rakesh

Hi...

SearchFilesDialog = new System.Windows.Forms.FolderBrowserDialog();
SearchFilesDialog.ShowDialog();

string ChosenFolder = SearchFilesDialog.SelectedPath.ToString();
DirectoryInfo FolderContent = new DirectoryInfo(ChosenFolder);
TBox_ShowFolderContent.Text = FolderContent.GetFiles().ToString();

Thank you
 
FS said:

you have to test whether ShowDialog was sucessful.

SearchFilesDialog = new System.Windows.Forms.FolderBrowserDialog();
if (SearchFilesDialog.ShowDialog() == DialogResult.OK) {
string ChosenFolder = SearchFilesDialog.SelectedPath;
DirectoryInfo FolderContent = new DirectoryInfo(ChosenFolder);
TBox_ShowFolderContent.Text = FolderContent.GetFiles().ToString();
}

bye
Rob
 
Robert Jordan said:
you have to test whether ShowDialog was sucessful.

SearchFilesDialog = new System.Windows.Forms.FolderBrowserDialog();
if (SearchFilesDialog.ShowDialog() == DialogResult.OK) {
string ChosenFolder = SearchFilesDialog.SelectedPath;
DirectoryInfo FolderContent = new DirectoryInfo(ChosenFolder);
TBox_ShowFolderContent.Text = FolderContent.GetFiles().ToString();
}

bye
Rob

I forgot, thx :)
but that didn't solve the problem at all... it always throws the exception
"The second pathfragment must not be a drive letter or UNC-Name" and
highlights the last line in wich i call the GetFiles-Method...

Thank You
 
Back
Top