Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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)

C#
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 6:23am
v2

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.
 
Share this answer
 
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?
 
Share this answer
 
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[^]
 
Share this answer
 
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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900