473,800 Members | 2,523 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetFiles problem

FS
hi guys

i wanna list the files of a user-chosen directory using getfiles(path). ..
path is in this case SearchFilesDial og.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
Nov 16 '05 #1
4 1335
Hi,

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

- Rakesh

"FS" wrote:
hi guys

i wanna list the files of a user-chosen directory using getfiles(path). ..
path is in this case SearchFilesDial og.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

Nov 16 '05 #2
FS


"Rakesh Rajan" wrote:
Hi,

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

- Rakesh


Hi...

SearchFilesDial og = new System.Windows. Forms.FolderBro wserDialog();
SearchFilesDial og.ShowDialog() ;

string ChosenFolder = SearchFilesDial og.SelectedPath .ToString();
DirectoryInfo FolderContent = new DirectoryInfo(C hosenFolder);
TBox_ShowFolder Content.Text = FolderContent.G etFiles().ToStr ing();

Thank you
Nov 16 '05 #3
FS wrote:

"Rakesh Rajan" wrote:

Hi,

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

- Rakesh

Hi...


you have to test whether ShowDialog was sucessful.

SearchFilesDial og = new System.Windows. Forms.FolderBro wserDialog();
if (SearchFilesDia log.ShowDialog( ) == DialogResult.OK ) {
string ChosenFolder = SearchFilesDial og.SelectedPath ;
DirectoryInfo FolderContent = new DirectoryInfo(C hosenFolder);
TBox_ShowFolder Content.Text = FolderContent.G etFiles().ToStr ing();
}

bye
Rob
Nov 16 '05 #4
FS


"Robert Jordan" wrote:
FS wrote:

"Rakesh Rajan" wrote:

Hi,

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

- Rakesh

Hi...


you have to test whether ShowDialog was sucessful.

SearchFilesDial og = new System.Windows. Forms.FolderBro wserDialog();
if (SearchFilesDia log.ShowDialog( ) == DialogResult.OK ) {
string ChosenFolder = SearchFilesDial og.SelectedPath ;
DirectoryInfo FolderContent = new DirectoryInfo(C hosenFolder);
TBox_ShowFolder Content.Text = FolderContent.G etFiles().ToStr ing();
}

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
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
20218
by: Demetri | last post by:
Using the GetFiles method of the DirectoryInfo instance one can pass in a search pattern of string type. For example: DirectoryInfo di = new DirectoryInfo("C:\temp"); FileInfo fi = di.GetFiles("*.doc"); That code would return all the files with the doc extension in the C:\temp folder. No problem.
3
30590
by: S. Han | last post by:
I'm using Directory.GetFiles to enumerate files in a directory. The problem is if you have to enumerate all files + subdirectories recursively, it takes too much memory, and it fails. Is there another way to enumerate files and subdirectories recursively which doesn't take too much memory in CS?
1
1224
by: huzz | last post by:
when i run the code below to search my entire c drive.. i get this following error message: Access to the path "c:\System Volume Information" is denied. Line 29: foreach (string f in Directory.GetFiles(d, ".mp3")) In web.config i have <identity impersonate="true"/> When i run the same code in Windows Form it works fine, also i like to know how i can put the results into an array instead of using response.write.
5
6498
by: CJ Taylor | last post by:
Hey Everyone, Sorry haven't been around to answer questions as much as usual (or at all for that matter) just been engrossed in a project. Anyways, dealing with an issue using DirectoryInfo.GetFiles wondering if anyone had the same issues I built my function to get the files, using a searchPattern filter (*.tif) in which case I have about a gig of files in this directory (about 5000 files) and using getFiles is slower than anything I...
13
2640
by: Tom Scales | last post by:
OK, I admit, I am not a VB.NET expert and am still learning, but have run into an annoying problem. I'm writing a program that has to search the file system and therefore processes large numbers of directories and files. I've figured out DirectoryInfo (it's pretty simple), but when I invoke DirectoryInfo.GetFiles (or even DirectoryInfo.GetDirectories), it can take forever. Some of the directories have thousands of files in them. So, my...
1
1767
by: Starbuck | last post by:
Hi When the routine below is run it gets to the line - Dim fileEntries As String() = Directory.GetFiles(tString) and then freezes, there is no errors etc, the program just stops responding. The path is correct and does exist and there is a test file in there Any thoughts please? Private Sub InboxTimer_Tick(ByVal sender As System.Object, ByVal e As
7
4300
by: Chris | last post by:
Hi everyone, I'm trying to find the fastest way to get all the files from the local c: drive. I have even considered the api calls findfirst/findnext, but read that in VB.net it's best to use the GetFiles function. I'm using: Dim files As String() = System.IO.Directory.GetFiles("c:\", "*.*", IO.SearchOption.AllDirectories)
13
8573
by: Lance | last post by:
Hi All, I'm working on a program that requires searching multiple drives for multiple file types and cataloging them based on certain geospatial attributes. All together, there are hundreds of thousands of files on the drives. As part of the process, I'm currently using the GetFiles method of the FileSystem object to retrieve collection of strings representing a collection of a particular file type (for example, tif files). The problem...
3
4159
by: cjb | last post by:
Is there a way to get Directory.GetFiles to return multi-language file names? I haven't found any overloads that allow any such parameter. The way I am using it now is: foreach (string d in Directory.GetDirectories("C:\\")) { foreach (string f in Directory.GetFiles(d, "*.exe")) { MessageBox.Show(f); } }
9
4635
by: Julie Smith | last post by:
Hi, Is it just me or does the search pattern parameter in Directory.GetFiles() have a problem with the '?' character? '*.*' works to find all files, but '?.*' does not work to find all files that have only a one letter (and infinite extension size) filename. In fact, it seems to act the same as '*.*'... Is this by design?
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10250
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5469
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.