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. Error Uploading! please help.

Error Uploading! please help.

Scheduled Pinned Locked Moved ASP.NET
helpdatabasesysadmindata-structuresdebugging
10 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.
  • J Offline
    J Offline
    Junior Boy
    wrote on last edited by
    #1

    I have been trying all day to upload text file to server but I have this error. Is something wrong? Anybody who know how to solve this problem please help me out. ================================================================================================ Server Error in '/' Application. -------------------------------------------------------------------------------- Could not find a part of the path 'D:\webhost\TextFiles\mydata.txt'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\webhost\TextFiles\mydata.txt'. Source Error: Line 75: { Line 76: fileName = Server.MapPath("//TextFiles//mydata.txt"); Line 77: FileUpload.PostedFile.SaveAs(Server.MapPath("//TextFiles//mydata.txt")); Line 78: input = ""; Line 79: Source File: d:\webhost\471463016\Index.aspx Line: 77 ================================================================================================== Thank you so very much,

    junior boy

    P S 2 Replies Last reply
    0
    • J Junior Boy

      I have been trying all day to upload text file to server but I have this error. Is something wrong? Anybody who know how to solve this problem please help me out. ================================================================================================ Server Error in '/' Application. -------------------------------------------------------------------------------- Could not find a part of the path 'D:\webhost\TextFiles\mydata.txt'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\webhost\TextFiles\mydata.txt'. Source Error: Line 75: { Line 76: fileName = Server.MapPath("//TextFiles//mydata.txt"); Line 77: FileUpload.PostedFile.SaveAs(Server.MapPath("//TextFiles//mydata.txt")); Line 78: input = ""; Line 79: Source File: d:\webhost\471463016\Index.aspx Line: 77 ================================================================================================== Thank you so very much,

      junior boy

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Cunningly enough, the exception tells you what is wrong. The path D:\webhost\textfiles\ isn't valid. I'm going to guess here that the TextFiles directory isn't present at this location.

      Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

      1 Reply Last reply
      0
      • J Junior Boy

        I have been trying all day to upload text file to server but I have this error. Is something wrong? Anybody who know how to solve this problem please help me out. ================================================================================================ Server Error in '/' Application. -------------------------------------------------------------------------------- Could not find a part of the path 'D:\webhost\TextFiles\mydata.txt'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path 'D:\webhost\TextFiles\mydata.txt'. Source Error: Line 75: { Line 76: fileName = Server.MapPath("//TextFiles//mydata.txt"); Line 77: FileUpload.PostedFile.SaveAs(Server.MapPath("//TextFiles//mydata.txt")); Line 78: input = ""; Line 79: Source File: d:\webhost\471463016\Index.aspx Line: 77 ================================================================================================== Thank you so very much,

        junior boy

        S Offline
        S Offline
        Sandeep Akhare
        wrote on last edited by
        #3

        I think you are not providing the proper path Are you sure TextFiles folder exist in your application

        Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

        J 1 Reply Last reply
        0
        • S Sandeep Akhare

          I think you are not providing the proper path Are you sure TextFiles folder exist in your application

          Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

          J Offline
          J Offline
          Junior Boy
          wrote on last edited by
          #4

          I tried to run on localhost on my computer it work fine but it didn't work on my server. I'm not sure how to coding for proper path on the server please see. FileUpload.PostedFile.SaveAs(Server.MapPath("TextFiles//mydata.txt")); //Is this right? If I have my webhost like this ftp://webhost.example.com/... <-- and I put all file and folder here. And i'm sure I the TextFiles folder is existed. Thank you million sir,

          junior boy

          S P 2 Replies Last reply
          0
          • J Junior Boy

            I tried to run on localhost on my computer it work fine but it didn't work on my server. I'm not sure how to coding for proper path on the server please see. FileUpload.PostedFile.SaveAs(Server.MapPath("TextFiles//mydata.txt")); //Is this right? If I have my webhost like this ftp://webhost.example.com/... <-- and I put all file and folder here. And i'm sure I the TextFiles folder is existed. Thank you million sir,

            junior boy

            S Offline
            S Offline
            Sandeep Akhare
            wrote on last edited by
            #5

            OK Can't you access that and see folder exist or not .......... Ok you can do one thing before uploading a file First check the Directory TextFiles exist or not if it not present there create with same name and put your file in that directory What you think my friend ?;)

            Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

            1 Reply Last reply
            0
            • J Junior Boy

              I tried to run on localhost on my computer it work fine but it didn't work on my server. I'm not sure how to coding for proper path on the server please see. FileUpload.PostedFile.SaveAs(Server.MapPath("TextFiles//mydata.txt")); //Is this right? If I have my webhost like this ftp://webhost.example.com/... <-- and I put all file and folder here. And i'm sure I the TextFiles folder is existed. Thank you million sir,

              junior boy

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              The standard way of doing this would be to do the following:

              if (!Directory.Exists(Server.MapPath("/TextFiles")))
                Directory.Create(Server.MapPath("/TextFiles"));
              

              Then, you can do the save as operation. Note that the asp worker process will need permissions to write into your directory structure to do this.

              Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

              J 2 Replies Last reply
              0
              • P Pete OHanlon

                The standard way of doing this would be to do the following:

                if (!Directory.Exists(Server.MapPath("/TextFiles")))
                  Directory.Create(Server.MapPath("/TextFiles"));
                

                Then, you can do the save as operation. Note that the asp worker process will need permissions to write into your directory structure to do this.

                Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

                J Offline
                J Offline
                Junior Boy
                wrote on last edited by
                #7

                I am really appreciated all your help sir. I don't get it work yet but I am trying. Thank you for all replied message again sir,

                junior boy

                1 Reply Last reply
                0
                • P Pete OHanlon

                  The standard way of doing this would be to do the following:

                  if (!Directory.Exists(Server.MapPath("/TextFiles")))
                    Directory.Create(Server.MapPath("/TextFiles"));
                  

                  Then, you can do the save as operation. Note that the asp worker process will need permissions to write into your directory structure to do this.

                  Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

                  J Offline
                  J Offline
                  Junior Boy
                  wrote on last edited by
                  #8

                  I have been trying to upload all last night:( please see this code: ================================================================================ string fileName = Server.MapPath("~/471463016/TextFiles/"); if(Directory.Exists(fileName)) Response.Write("Existed"); else { Directory.CreateDirectory(fileName); Response.Write("Not Exist"); } ================================================================================ It shows me message: Existed And then please see code: ================================================================================ Response.Write("Path = "+fileName); try { FileUpload.PostedFile.SaveAs(fileName+"mydata.txt"); } catch(Execption ex){ Response.Write("
                  Error: " + ex.Message); } ================================================================================ The result : Path = D:\webhost\471463016\TextFiles\ Error: Access to the path 'D:\webhost\471463016\TextFiles\mydata.txt' is denied. I don't really understand why I have the error when it show me the folder path is existed. Believe me, I have been try so hard as i have never tried, I really need help because I have deadline on July 7 Saturday to send my school project,sir. Again, anyhelp will be really appreciated. My email : big_kh@hotmail.com Thank you million,

                  junior boy

                  P 1 Reply Last reply
                  0
                  • J Junior Boy

                    I have been trying to upload all last night:( please see this code: ================================================================================ string fileName = Server.MapPath("~/471463016/TextFiles/"); if(Directory.Exists(fileName)) Response.Write("Existed"); else { Directory.CreateDirectory(fileName); Response.Write("Not Exist"); } ================================================================================ It shows me message: Existed And then please see code: ================================================================================ Response.Write("Path = "+fileName); try { FileUpload.PostedFile.SaveAs(fileName+"mydata.txt"); } catch(Execption ex){ Response.Write("
                    Error: " + ex.Message); } ================================================================================ The result : Path = D:\webhost\471463016\TextFiles\ Error: Access to the path 'D:\webhost\471463016\TextFiles\mydata.txt' is denied. I don't really understand why I have the error when it show me the folder path is existed. Believe me, I have been try so hard as i have never tried, I really need help because I have deadline on July 7 Saturday to send my school project,sir. Again, anyhelp will be really appreciated. My email : big_kh@hotmail.com Thank you million,

                    junior boy

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #9

                    Check your permissions. ASP.NET applications run under a special worker process and this process will need permissions to write to the file system.

                    Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

                    J 1 Reply Last reply
                    0
                    • P Pete OHanlon

                      Check your permissions. ASP.NET applications run under a special worker process and this process will need permissions to write to the file system.

                      Please visit http://www.readytogiveup.com/ and do something special today. Deja View - the feeling that you've seen this post before.

                      J Offline
                      J Offline
                      Junior Boy
                      wrote on last edited by
                      #10

                      Thank gosh... Finally my project every thing worked right:) I am really exited and it worthwhile on have been tried hard. Thank you for all help again,sir.:rose::-D If you would like to visit my small project here is the link Click here -- modified at 0:48 Thursday 5th July, 2007

                      junior boy

                      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