Click here to Skip to main content
14,392,016 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everyone,

When I run the following code through Visual Studio, I can access the sherd folder and get information.
when I publish the final plan with .aspx page through iis and went to the link and follow the same steps I can not get information.


(I develop under the organization with the active directory)

private static long GetDirectorySize(string folderPath)
    {
        DirectoryInfo di = new DirectoryInfo(folderPath);
        return di.EnumerateFiles("*", SearchOption.AllDirectories).Sum(fi => fi.Length);
    }


Something that can help me?
Posted
Updated 20-Aug-15 7:23am
v2
Rate this:
Please Sign up or sign in to vote.

Solution 3

When you run from Visual studio it will get the access privileges of the user who running visual studio, but when you host this web site in IIS it will only have IIS user access as default, but you can change the app pool user to another user who having access to network sharers etc.. then only your IIS web site can access shared folders.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

Your folderPath string variable is context-sensitive; it means that a given path on your development machine does not point to the same location when it is used on the server.

What is the value of this variable?
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

The account your asp.net code runs under by default does not have access to the network, or shares on other machines. You'll need to change the account your code is running under to an account that has the required access.

https://technet.microsoft.com/en-us/library/cc770966(v=ws.10).aspx[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

It worked and helped me solve other problems, like getting a username from computer client .

It worked when I put the username with privileges on "asp.net Impersonation"

tank's everybody
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100