Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Access to the path '' is denied

Access to the path '' is denied

Scheduled Pinned Locked Moved ASP.NET
helpcsharpdotnetsysadmintesting
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sebastian T Xavier
    wrote on last edited by
    #1

    Hello All, I was testing a simple program to upload files to sever , but it failed with the following error message. "Access to the path '' is denied" I am using .Net Framework 3.5 in windows 7 machine. The code i have used is given below.

    private void cmdSend\_Click(object sender, System.EventArgs e)
        {
            // Check to see if file was uploaded
            if (filMyFile.PostedFile != null)
            {
                // Get a reference to PostedFile object
                HttpPostedFile myFile = filMyFile.PostedFile;
                int nFileLen = myFile.ContentLength;
                if (nFileLen > 0)
                {
                    byte\[\] myData = new byte\[nFileLen\];
                    myFile.InputStream.Read(myData, 0, nFileLen);
                    string strFilename = Path.GetFileName(myFile.FileName);
    				//WriteToFile(Server.MapPath(strFilename), ref myData);//WORKING
                    //WriteToFile(@"\\\\192.168.1.127\\Temp", ref myData);//NOT WORKING
                    WriteToFile(@"D:\\Temp", ref myData);//NOT WORKING
                }
            }
        }
    
    private void WriteToFile(string strPath, ref byte\[\] Buffer)
        {
             FileStream newFile = new FileStream(strPath, FileMode.Create);
             newFile.Write(Buffer, 0, Buffer.Length);
             newFile.Close();
        }
    

    Can someone help me? Thanks in Advance... Sebastian

    R T 2 Replies Last reply
    0
    • S Sebastian T Xavier

      Hello All, I was testing a simple program to upload files to sever , but it failed with the following error message. "Access to the path '' is denied" I am using .Net Framework 3.5 in windows 7 machine. The code i have used is given below.

      private void cmdSend\_Click(object sender, System.EventArgs e)
          {
              // Check to see if file was uploaded
              if (filMyFile.PostedFile != null)
              {
                  // Get a reference to PostedFile object
                  HttpPostedFile myFile = filMyFile.PostedFile;
                  int nFileLen = myFile.ContentLength;
                  if (nFileLen > 0)
                  {
                      byte\[\] myData = new byte\[nFileLen\];
                      myFile.InputStream.Read(myData, 0, nFileLen);
                      string strFilename = Path.GetFileName(myFile.FileName);
      				//WriteToFile(Server.MapPath(strFilename), ref myData);//WORKING
                      //WriteToFile(@"\\\\192.168.1.127\\Temp", ref myData);//NOT WORKING
                      WriteToFile(@"D:\\Temp", ref myData);//NOT WORKING
                  }
              }
          }
      
      private void WriteToFile(string strPath, ref byte\[\] Buffer)
          {
               FileStream newFile = new FileStream(strPath, FileMode.Create);
               newFile.Write(Buffer, 0, Buffer.Length);
               newFile.Close();
          }
      

      Can someone help me? Thanks in Advance... Sebastian

      R Offline
      R Offline
      R Giskard Reventlov
      wrote on last edited by
      #2

      Yu're being told that your application does not have the requisite permissions to the folder you are attempting to access.

      "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

      1 Reply Last reply
      0
      • S Sebastian T Xavier

        Hello All, I was testing a simple program to upload files to sever , but it failed with the following error message. "Access to the path '' is denied" I am using .Net Framework 3.5 in windows 7 machine. The code i have used is given below.

        private void cmdSend\_Click(object sender, System.EventArgs e)
            {
                // Check to see if file was uploaded
                if (filMyFile.PostedFile != null)
                {
                    // Get a reference to PostedFile object
                    HttpPostedFile myFile = filMyFile.PostedFile;
                    int nFileLen = myFile.ContentLength;
                    if (nFileLen > 0)
                    {
                        byte\[\] myData = new byte\[nFileLen\];
                        myFile.InputStream.Read(myData, 0, nFileLen);
                        string strFilename = Path.GetFileName(myFile.FileName);
        				//WriteToFile(Server.MapPath(strFilename), ref myData);//WORKING
                        //WriteToFile(@"\\\\192.168.1.127\\Temp", ref myData);//NOT WORKING
                        WriteToFile(@"D:\\Temp", ref myData);//NOT WORKING
                    }
                }
            }
        
        private void WriteToFile(string strPath, ref byte\[\] Buffer)
            {
                 FileStream newFile = new FileStream(strPath, FileMode.Create);
                 newFile.Write(Buffer, 0, Buffer.Length);
                 newFile.Close();
            }
        

        Can someone help me? Thanks in Advance... Sebastian

        T Offline
        T Offline
        thatraja
        wrote on last edited by
        #3

        You have two options. Choose an option you want 1)Windows 7 - Sharing and Permissions[^] 2)How to implement impersonation in an ASP.NET application[^]

        thatraja

        FREE Code Conversion VB6 ASP VB.NET C# ASP.NET C++ JAVA PHP DELPHI ColdFusion
        HTML Marquee & its alternatives

        Nobody remains a virgin, Life screws everyone :sigh:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups