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. Not a valid virtual path

Not a valid virtual path

Scheduled Pinned Locked Moved ASP.NET
helpsysadminquestion
11 Posts 2 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
    samerh
    wrote on last edited by
    #1

    Got an error when i deployed not a valid virtual path. though i have added permissions to image folder on the server. Iam using a function that returns save location and uploads the image. this is the code iam using:

    Private Function Uploaded() As String
    Dim filePath As String = AppSettings("~\Images")
    Dim SaveLocation As String = String.Empty
    If Not txtImgURL.Text.Length = 0 And Left(txtImgURL.Text, filePath.Length) <> filePath Then
    Dim fileName As String = System.IO.Path.GetFileNameWithoutExtension(txtImgURL.Text).ToLower()
    Dim fileExtention As String = System.IO.Path.GetExtension(txtImgURL.Text).ToLower()
    SaveLocation = System.IO.Path.Combine(filePath, fileName & fileExtention)
    Dim physicalLocation As String = Server.MapPath(SaveLocation)

            If File.Exists(physicalLocation) = True Then
                Dim sequencer As Integer = 1
                SaveLocation = System.IO.Path.Combine(filePath, fileName & "\_" & sequencer.ToString & fileExtention)
                physicalLocation = Server.MapPath(SaveLocation)
    
                Try
                    My.Computer.FileSystem.CopyFile(txtImgURL.Text, physicalLocation)
                Catch
                    My.Computer.FileSystem.CopyFile(Server.MapPath(txtImgURL.Text), physicalLocation)
                End Try
            Else
                Try
                    My.Computer.FileSystem.CopyFile(txtImgURL.Text, physicalLocation)
                Catch
                    My.Computer.FileSystem.CopyFile(Server.MapPath(txtImgURL.Text), physicalLocation)
                End Try
            End If
        End If
        Return SaveLocation
    End Function
    

    Any help?

    H 1 Reply Last reply
    0
    • S samerh

      Got an error when i deployed not a valid virtual path. though i have added permissions to image folder on the server. Iam using a function that returns save location and uploads the image. this is the code iam using:

      Private Function Uploaded() As String
      Dim filePath As String = AppSettings("~\Images")
      Dim SaveLocation As String = String.Empty
      If Not txtImgURL.Text.Length = 0 And Left(txtImgURL.Text, filePath.Length) <> filePath Then
      Dim fileName As String = System.IO.Path.GetFileNameWithoutExtension(txtImgURL.Text).ToLower()
      Dim fileExtention As String = System.IO.Path.GetExtension(txtImgURL.Text).ToLower()
      SaveLocation = System.IO.Path.Combine(filePath, fileName & fileExtention)
      Dim physicalLocation As String = Server.MapPath(SaveLocation)

              If File.Exists(physicalLocation) = True Then
                  Dim sequencer As Integer = 1
                  SaveLocation = System.IO.Path.Combine(filePath, fileName & "\_" & sequencer.ToString & fileExtention)
                  physicalLocation = Server.MapPath(SaveLocation)
      
                  Try
                      My.Computer.FileSystem.CopyFile(txtImgURL.Text, physicalLocation)
                  Catch
                      My.Computer.FileSystem.CopyFile(Server.MapPath(txtImgURL.Text), physicalLocation)
                  End Try
              Else
                  Try
                      My.Computer.FileSystem.CopyFile(txtImgURL.Text, physicalLocation)
                  Catch
                      My.Computer.FileSystem.CopyFile(Server.MapPath(txtImgURL.Text), physicalLocation)
                  End Try
              End If
          End If
          Return SaveLocation
      End Function
      

      Any help?

      H Offline
      H Offline
      Herman T Instance
      wrote on last edited by
      #2

      to which user you added the rights?

      In Word you can only store 2 bytes. That is why I use Writer.

      S 1 Reply Last reply
      0
      • H Herman T Instance

        to which user you added the rights?

        In Word you can only store 2 bytes. That is why I use Writer.

        S Offline
        S Offline
        samerh
        wrote on last edited by
        #3

        i have added on folder images, the strange thing happening is that i can update an image already found but cant add a new image.

        H 1 Reply Last reply
        0
        • S samerh

          i have added on folder images, the strange thing happening is that i can update an image already found but cant add a new image.

          H Offline
          H Offline
          Herman T Instance
          wrote on last edited by
          #4

          which user and which rigths are added to the directory?

          In Word you can only store 2 bytes. That is why I use Writer.

          S 1 Reply Last reply
          0
          • H Herman T Instance

            which user and which rigths are added to the directory?

            In Word you can only store 2 bytes. That is why I use Writer.

            S Offline
            S Offline
            samerh
            wrote on last edited by
            #5

            I have added to the directory aspnet user with full control and network service with full control.

            H 2 Replies Last reply
            0
            • S samerh

              I have added to the directory aspnet user with full control and network service with full control.

              H Offline
              H Offline
              Herman T Instance
              wrote on last edited by
              #6

              that should be sufficient. The folder one level higher has both users with the rights? (back up to the root?)

              In Word you can only store 2 bytes. That is why I use Writer.

              1 Reply Last reply
              0
              • S samerh

                I have added to the directory aspnet user with full control and network service with full control.

                H Offline
                H Offline
                Herman T Instance
                wrote on last edited by
                #7

                is this folder somewhere within the wwwroot or have you placed outside wwwroot folder

                In Word you can only store 2 bytes. That is why I use Writer.

                S 1 Reply Last reply
                0
                • H Herman T Instance

                  is this folder somewhere within the wwwroot or have you placed outside wwwroot folder

                  In Word you can only store 2 bytes. That is why I use Writer.

                  S Offline
                  S Offline
                  samerh
                  wrote on last edited by
                  #8

                  I have tried both inside and outside but now it is inside

                  H 1 Reply Last reply
                  0
                  • S samerh

                    I have tried both inside and outside but now it is inside

                    H Offline
                    H Offline
                    Herman T Instance
                    wrote on last edited by
                    #9

                    has wwwroot full control for asp_net user and network_Service ?

                    In Word you can only store 2 bytes. That is why I use Writer.

                    S 1 Reply Last reply
                    0
                    • H Herman T Instance

                      has wwwroot full control for asp_net user and network_Service ?

                      In Word you can only store 2 bytes. That is why I use Writer.

                      S Offline
                      S Offline
                      samerh
                      wrote on last edited by
                      #10

                      yes indeed

                      H 1 Reply Last reply
                      0
                      • S samerh

                        yes indeed

                        H Offline
                        H Offline
                        Herman T Instance
                        wrote on last edited by
                        #11

                        well, that makes it a curious case. I believe that if you pick Full Control you could still set some other options if you pick the Edit button.

                        In Word you can only store 2 bytes. That is why I use Writer.

                        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