“Access to this path is denied” in Windows 7 application
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: “Access to this path is denied” in Windows 7 application

  1. #1
    Join Date
    Apr 2014
    Posts
    2

    “Access to this path is denied” in Windows 7 application

    Ran into a strange phenomena:

    in Application A, the
    Code:
    Using sr = New StreamReader(pathDir)
    runs perfectly (where pathDir is C:\tmp for example. This directory is on the local machine and I have full permissions).
    In Application B the same line, on the same directory (on the same machine) throws the exception: "Access to the path is denied".
    The code checks that the directory is not read-only before trying to create the streamReader.
    This happens when run in the IDE or by activating the exe file.

    Some additional information:
    Windows 7 Pro, 64bit, VS 2013 (same happens with VS2010 generated app).
    The app.manifest of both application is identical. I've tried changing to all possible options of requestedExecutionLevel but the result was the same.
    The target framework of the application is 4.
    The exception is thrown whether I run as administrator or not.
    I've set the permissions of the directory to full control for all accounts (including Administrator and Everyone).
    I've deleted the directory and recreated it. Didn't help.
    Ran Farbar and Avira scan which did not report any problems.

    Any advice will be much appreciated,
    Amir

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,851

    Re: “Access to this path is denied” in Windows 7 application

    If I'm not mistaken streamreader expects a filename.
    I would expect the code above to try to open a file in C:\ named tmp and would not be surprised to get this error. I would be surprised if I did not get the error.

    Try specifying a filename in your tmp folder and see what happens
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Apr 2014
    Posts
    2

    Re: “Access to this path is denied” in Windows 7 application

    Quote Originally Posted by DataMiser View Post
    If I'm not mistaken streamreader expects a filename.
    I would expect the code above to try to open a file in C:\ named tmp and would not be surprised to get this error. I would be surprised if I did not get the error.

    Try specifying a filename in your tmp folder and see what happens
    Yeh, you are absolutely right, and I'm feeling awkward..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center