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.Direc tory.GetFiles(" c:\", "*.*",
IO.SearchOption .AllDirectories )
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System
Volume Information' is denied."
Is there any way I can just ignore the exception and have the program
continue where it left off?
Thanks,
Chris 7 4296
Put a Try/Catch around that line, then do nothing in the catch. In the code
following the try/catch, make sure you are not relying on GetFiles
succeeding.
"Chris" <co***********@ nospam.yahoo.co mwrote in message
news:ei******** ******@TK2MSFTN GP05.phx.gbl...
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.Direc tory.GetFiles(" c:\", "*.*",
IO.SearchOption .AllDirectories )
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System
Volume Information' is denied."
Is there any way I can just ignore the exception and have the program
continue where it left off?
Thanks,
Chris
Hi Marina,
The problem with this solution is that I need the GetFiles to pickup where
it left off.
The end result should be an array that contains every file on my c: drive.
What else can I do?
Thanks,
Chris
"Marina Levit [MVP]" <so*****@nospam .comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Put a Try/Catch around that line, then do nothing in the catch. In the
code following the try/catch, make sure you are not relying on GetFiles
succeeding.
"Chris" <co***********@ nospam.yahoo.co mwrote in message
news:ei******** ******@TK2MSFTN GP05.phx.gbl...
>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.Direc tory.GetFiles(" c:\", "*.*", IO.SearchOptio n.AllDirectorie s)
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System Volume Information' is denied."
Is there any way I can just ignore the exception and have the program continue where it left off?
Thanks,
Chris
That's not the same as ignoring the error thrown and continue with your
code. Please be clear in what you want to do.
It sounds like you just need this code to work instead of throwing the
exception. In which case, the user your executable is running under needs
sufficient permissions to get all the files on the drive. Right now this
user does not have these permissions.
"Chris" <co***********@ nospam.yahoo.co mwrote in message
news:Oa******** *****@TK2MSFTNG P05.phx.gbl...
Hi Marina,
The problem with this solution is that I need the GetFiles to pickup where
it left off.
The end result should be an array that contains every file on my c: drive.
What else can I do?
Thanks,
Chris
"Marina Levit [MVP]" <so*****@nospam .comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
>Put a Try/Catch around that line, then do nothing in the catch. In the code following the try/catch, make sure you are not relying on GetFiles succeeding.
"Chris" <co***********@ nospam.yahoo.co mwrote in message news:ei******* *******@TK2MSFT NGP05.phx.gbl.. .
>>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.Direc tory.GetFiles(" c:\", "*.*", IO.SearchOpti on.AllDirectori es)
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System Volume Information' is denied."
Is there any way I can just ignore the exception and have the program continue where it left off?
Thanks,
Chris
The followinig code works, but I'm looking for something even faster.
Public Function RecursiveSearch (ByRef array As ArrayList, _
ByVal strDir As String, ByVal bwWorker As BackgroundWorke r, _
ByVal e As DoWorkEventArgs ) As Boolean
Dim dirInfo As New IO.DirectoryInf o(strDir)
' Try to get the files for this directory
Dim pFileInfo() As IO.FileInfo
Try
pFileInfo = dirInfo.GetFile s()
Catch ex As UnauthorizedAcc essException
Return False
Exit Function
End Try
' Add the file infos to the array
array.AddRange( pFileInfo)
'report progress, raises progress changed event
bwWorker.Report Progress(array. Count)
' Try to get the subdirectories of this one
Dim pdirInfo() As IO.DirectoryInf o
Try
pdirInfo = dirInfo.GetDire ctories()
Catch ex As UnauthorizedAcc essException
Return False
Exit Function
End Try
' Iterate through each directory and recurse
Dim dirIter As IO.DirectoryInf o
For Each dirIter In pdirInfo
If bwWorker.Cancel lationPending Then
e.Cancel = True
Else
RecursiveSearch (array, dirIter.FullNam e, bwWorker, e)
End If
Next dirIter
Return True
End Function
"Marina Levit [MVP]" <so*****@nospam .comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Put a Try/Catch around that line, then do nothing in the catch. In the
code following the try/catch, make sure you are not relying on GetFiles
succeeding.
"Chris" <co***********@ nospam.yahoo.co mwrote in message
news:ei******** ******@TK2MSFTN GP05.phx.gbl...
>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.Direc tory.GetFiles(" c:\", "*.*", IO.SearchOptio n.AllDirectorie s)
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System Volume Information' is denied."
Is there any way I can just ignore the exception and have the program continue where it left off?
Thanks,
Chris
Perhaps a crazy idea... How about getting the result of
dir *.* /b/s
and appling a split function to the result ?
-tom
Marina Levit [MVP] ha scritto:
That's not the same as ignoring the error thrown and continue with your
code. Please be clear in what you want to do.
It sounds like you just need this code to work instead of throwing the
exception. In which case, the user your executable is running under needs
sufficient permissions to get all the files on the drive. Right now this
user does not have these permissions.
"Chris" <co***********@ nospam.yahoo.co mwrote in message
news:Oa******** *****@TK2MSFTNG P05.phx.gbl...
Hi Marina,
The problem with this solution is that I need the GetFiles to pickup where
it left off.
The end result should be an array that contains every file on my c: drive.
What else can I do?
Thanks,
Chris
"Marina Levit [MVP]" <so*****@nospam .comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Put a Try/Catch around that line, then do nothing in the catch. In the
code following the try/catch, make sure you are not relying on GetFiles
succeeding.
"Chris" <co***********@ nospam.yahoo.co mwrote in message
news:ei******** ******@TK2MSFTN GP05.phx.gbl... 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.Direc tory.GetFiles(" c:\", "*.*", IO.SearchOptio n.AllDirectorie s)
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System Volume Information' is denied."
Is there any way I can just ignore the exception and have the program continue where it left off?
Thanks,
Chris
This will work too....
Private FileList As String = ""
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
GetFiles("C:\")
FileList = FileList.TrimEn d(",")
ListBox1.DataSo urce = FileList.Split( ",")
End Sub
Private Sub GetFiles(ByVal Path As String)
Dim SubDirs() As IO.DirectoryInf o
Dim SubDir As IO.DirectoryInf o
Dim Files() As IO.FileInfo
Dim File As IO.FileInfo
Dim CurDir As New IO.DirectoryInf o(Path)
Files = CurDir.GetFiles
If Not Files Is Nothing Then
For Each File In Files
FileList = FileList & File.Name & ","
Next
End If
SubDirs = CurDir.GetDirec tories
If Not SubDirs Is Nothing Then
For Each SubDir In SubDirs
Try
GetFiles(SubDir .FullName)
Catch ex As Exception
'Do Nothing
End Try
Next
End If
End Sub
Chris wrote:
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.Direc tory.GetFiles(" c:\", "*.*",
IO.SearchOption .AllDirectories )
and get UnAuthorizeExce ption was unhandled: "Access to the path 'c:\System
Volume Information' is denied."
Is there any way I can just ignore the exception and have the program
continue where it left off?
I haven't reied this yet on a boot device, but you can give it a try: http://groups.google.com/group/micro...ef110c6e2eece5 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jonathan Allen |
last post by:
MSDN> "The matching behavior of searchPattern when the extension is exactly
three characters long is different from when the extension is more than
three characters long. A searchPattern of exactly three characters returns
files having an extension of three or more characters. A searchPattern of
one, two, or more than three characters returns only files having extensions
of exactly that length."
WHAT THE <BLEEP> WERE THEY THINKING!
...
|
by: FS |
last post by:
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
|
by: ALI-R |
last post by:
I am using the follwoing code to get all files which have txt as an
extension but I get an error that your search pattern is not correct.it
seems this fuction dosn't accept "*.txt" as search pattern.
Is there somebody can help me?
using System;
using System.IO;
class Test
|
by: brian |
last post by:
I am using the Directory.GetFiles class and am having
problems with the overloaded version. I want to search
files. I can use the following and it works fine:
Directory.GetFiles(Path, k)
Path: c:/Test/
k: 3
It will query all files in the test directory with a file
that is named 3.
|
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
| |
by: al jones |
last post by:
I'm using filesystem.getfiles - and so far it's working correctly *however*
I'd sure like to be able to pass it, as the last parameter, the extensions
(plural) for which I'm looking.
I assumed that "*.exe, *.dll" for example would work but it seems to not
like that syntax. Would someone correct my misinformation and give me a
way to pass more than a single pattern to that last parameter??
Thanks //al
|
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...
|
by: GregInHouston2 |
last post by:
I am attempting to access the files on a share on a server in my network so I can list the files there on an intranet web page.
At this point, the share permissions and the NTFS permissions are set so open that it scares me but my GetFiles() call still generates an "access denied" exception. I have even given "Everyone" read access to the share and read, read&execute, and list folder contents permision on NTFS.
The Directory Security...
|
by: Michael Jackson |
last post by:
In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to
get all the files in the directory. However, I'm getting an error regarding
"Illegal character in Path", even though I can copy, etc the file using the
Windows XP explorer.
I can trap the error, but then this traps the entire GetFiles() function,
not just the one bad file.
Is there a way to just trap for the one bad file and continue on?
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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,...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |