By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,327 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Working with files and folders

P: n/a
RTT
I can access a directory with this code in a windows form.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim strPath As String = "\\be0001\Users\josgijsens"
  3.  
  4. 'Dim strPath As String = "c:\"
  5.  
  6. Dim strFile, strDir As String
  7.  
  8. For Each strDir In Directory.GetDirectories(strPath)
  9.  
  10. RichTextBox1.AppendText(Path.GetFileName(strDir) & vbCrLf)
  11.  
  12. Next
  13.  
  14. For Each strFile In Directory.GetFiles(strPath)
  15.  
  16. RichTextBox1.AppendText(Path.GetFileName(strFile).ToString & vbCrLf)
  17.  
  18. Next
  19.  
  20.  


with this code i can read the directories and files on my harddisks or on an
network directory "\\be0001\Users\josgijsens".

My current problem is that i'm the user with rights on
"\\be0001\Users\josgijsens" but if i want to view an other folder
"\\be0001\Users\markwouters" i don't have the rights to do this. I should be
able to acces the folder as a different user. so before i try to access it i
should somehow make sure that i access it not as the user that run the code
but as a user given in codebased with rights to all folders. is that
possible?

in a web application it is possible to impersonate a user so the page
doesn't run as the default ASP.NET user. Is it possible to do the same with
a webform. i think the code runs under the default windows user, right? so
is their a way to run code as a different user like with web applications?

second question. you can search a folder with GetFiles(strPath, "*.mp3") but
that will only search in de current path and not in the subfolders. is there
a way to search a complete map including subfolder? of will i have to write
my recursive method myself?

thxs
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Lookup FileIOPermissions in the System.Security.Permissions namespace

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.