Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

search files and folders

search files and folders

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1 cloud

cloud

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 69 posts

Posted 20 November 2014 - 08:52 PM

i am making a program which is to search all files in a different folders and subfolders.. this is my code try{ string drive = @"D:\"; string[] file = Directory.GetFiles(drive,*.*,SearchOptions.AllDirectories); foreach(files in file) { listbox1.Items.Add(file); } } catch(unauthorizefileaccess uax) { textbox1.Text = uax; continue; } this code wont continue to load the files.. what should i do?

#2 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 22 November 2014 - 01:13 PM

What's the error you are getting?



#3 cloud

cloud

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 69 posts

Posted 30 November 2014 - 07:49 AM

The error is
Unauthorizefileaccess on
system volume information. Because of the searchoption.alldirectories.

#4 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 30 November 2014 - 08:18 AM

Well, The error is pretty clear, you aren't authorized to get into those files. You should run the program as administrator, or make the administrator grant your user permission over such files. Or  you can run your program as Administrator, if allowed of course.



#5 cloud

cloud

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 69 posts

Posted 02 December 2014 - 01:18 AM

So, it means, its not my code?what if I'm not allowed to access?what will I do?
So, it means, its not my code?what if I'm not allowed to access?what will I do?
So, it means, its not my code?what if I'm not allowed to access?what will I do?

#6 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 02 December 2014 - 04:58 AM

That's the great thing about system permissions: if you don't have access to a resource, you either don't have access for a reason, or you'll be able to get access.

 

With that said, do you not have access to ANY files on that drive, or just certain files?


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#7 cloud

cloud

    CC Resident

  • Advanced Member
  • PipPipPipPip
  • 69 posts

Posted 02 December 2014 - 06:30 AM

My program run on admin.. How can I access all the files on each directories and subdirectories including the file system using the searchoption.alldirectories??if file.exist then delete..I'm stuck on system volume information when being scan

#8 lespauled

lespauled

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1360 posts

Posted 02 December 2014 - 08:25 AM

Run it through a try-catch block.  Trap the permissions exception and just continue.


My Blog: http://forum.codecal...699-blog-77241/
"Women and Music: I'm always amazed by other people's choices." - David Lee Roth




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download