none
Access to the path '....' is denied

    General discussion

  • When I run the following command:

    infile = New FileStream(SOURCE_FILE, FileMode.Open, FileAccess.Read, FileShare.Read)   ' Open the file as a FileStream object.
    
    I am receiving the error message, Access to the path '....' is denied.  I have gone through the file/folder properties of my target folders and I thought I gave full access to the items I am targetting but it doesn't seem to help.  What else should I try to avoid this error?  Thank you!
    • Changed type Martin Xie - MSFT Tuesday, September 08, 2009 2:22 AM Change to comment due to no follow-up.
    Monday, August 31, 2009 4:40 PM

All replies

  • Is your application running on vista? And what's the path of Source file. Some system folders can only be changed by administrator user. Try running the application as administrator. (Right click the application exe and Select 'Run as administrator')
    Gaurav Khanna
    Monday, August 31, 2009 5:10 PM
  • I would think that the problem is with the path stored in the variable SOURCE_FILE.  Set a breakpoint somewhere after you set the path into that variable and check its contents.


    Doug

    SEARCH ... then ask
    Monday, August 31, 2009 5:11 PM
  • Im running it on xp...I would only like to read the data should I still try running as administrator?
    Monday, August 31, 2009 5:13 PM
  • Thank you for your responses.  I was able to figure out part of my issue, I was attempting to read in a directory and all of its contents and that is what is causing the error.  I take it the FileStream is not what I would want for this?
    Monday, August 31, 2009 5:19 PM
  • Im running it on xp...I would only like to read the data should I still try running as administrator?

    You havent answer the question from first 2 replies. They want to know what  path SOURCE_FILE represent?

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    Monday, August 31, 2009 5:23 PM
  • Ignore my previous post

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on
    Monday, August 31, 2009 5:24 PM
  • The source_file was a directory path, that is what was causing the error......  "U:\Corey\My Documents\Work For Bruce"

    Files seem to work fine but I just tried running it as administrator and it didn't work.
    Monday, August 31, 2009 5:27 PM
  • Thank you for your responses.  I was able to figure out part of my issue, I was attempting to read in a directory and all of its contents and that is what is causing the error.  I take it the FileStream is not what I would want for this?

    I guess the next question would be: what exactly are you trying to do? What is the file you are trying to read?
    Monday, August 31, 2009 5:47 PM
  • The one I am trying to read is a test with is a folder I just created on my desktop that consists of two simple text files I created for test purposes
    Monday, August 31, 2009 6:03 PM
  • and what are you doing with them when you "read" them? Opening the text into something like a RichTextBox? Are they lines of data to put in like a ListBox?

    knowing exactly what you are doing with the file, we might be able to come up with some alternative solutions other than FileStream
    Monday, August 31, 2009 6:09 PM
  • The one I am trying to read is a test with is a folder I just created on my desktop that consists of two simple text files I created for test purposes

    If they're just text files, how about just "read" them directly using My.Computer.FileSystem.ReadAllText ?
    Monday, August 31, 2009 7:39 PM
  • We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by clicking "Change Type" at the top of the thread. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.

    Tuesday, September 08, 2009 2:20 AM