Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone,
as i have discussed with you many times. today i am having problem with some exception that comes when i am trying to insert the file into database(pdf file). in local machine it's going well. but when i am trying to run this application on server then it's show some exception ,here is code of mine which i s running well in local machine :-


C#
protected void btnsave_Click(object sender, EventArgs e)
    {
        if (flUpld.HasFile == false)
        {
            lblerror.Text = "select a file to upload";
        }
        else
        {
            try
            {
                string filename = flUpld.FileName;
                find =Request.ApplicationPath;
                flUpld.PostedFile.SaveAs(Server.MapPath(find+"//result//" + filename.Trim()));
                string path = find+"//result//" + filename.Trim();

                if (ChangeData.InsertResult(ddlcategory.SelectedValue.ToString(), ddlsubcategory.SelectedValue.ToString(),
                txttitle.Text, path))
                {
                    txttitle.Text = "";
                    lblerror.Text = "sucessfully submitted";
                }
                else
                {
                    lblerror.Text = "try again later ";
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
    }



and when i am trying to upload this site on server and trying to insert then it show the error
exception :-



System.UnauthorizedAccessException: Access to the path 'D:\INETPUB\VHOSTS\sarkarirozgar.com\httpdocs\result\Andersens_Fairy_Tales_NT.pdf' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename) at ADMIN_Manage_Results.btnsave_Click(Object sender, EventArgs e) in d:\inetpub\vhosts\sarkarirozgar.com\httpdocs\ADMIN\Manage_Results.aspx.cs:line 70


help me out why it is going on because i have provided all the permission to the folder.. help me out.

my structure of the folder.

ADMIN PANEL
-manageresult.aspx
-manageresult.aspx.cs

result
userpanel

like this means the folder where i m trying to save the pdf file is in root. and the pages are under the admin folder .
Posted
Updated 20-Mar-13 21:19pm
v2
Comments
Bojjaiah 21-Mar-13 3:21am    
check your credentials.
amitkumar5734 21-Mar-13 3:22am    
means what i am not getting you..please specify your ans.. pls..
Bojjaiah 21-Mar-13 3:28am    
you do not have permission for file or drive. So, check your network permissions.
amitkumar5734 21-Mar-13 3:31am    
how can i check network permission.. i am using shared server . that a have purchased from a particular company , they told me that we have already provided all the permission. so please tell me how can i check my network settings while using shared server .

1 solution

1) Right click the required folder
2) Select Properties
3) Select tab Security
4) Click Add button
5) Under "Enter the object names to select(examples):" type ASPNET. Click "Check Names" button". Then Click OK.
6) Select ASPNET under "Group or user names:" Provide Read & Execute, Read and Write permissions. Click OK
7) Then again click Add button
8) Under "Enter the object names to select(examples):" type NETWORK SERVICE. Click "Check Names" button". Then Click OK.
9) Select NETWORK SERVICE under "Group or user names:" Provide Read & Execute, Read and Write permissions. Click OK
 
Share this answer
 
v3
Comments
amitkumar5734 21-Mar-13 3:46am    
there is a option of change permission for directory ... then in further ..

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