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. Upload File

Upload File

Scheduled Pinned Locked Moved ASP.NET
help
7 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.
  • V Offline
    V Offline
    vengaqua
    wrote on last edited by
    #1

    i am doing this for uploding the file in the specified directory. But it gives error after the line which i have bolded. Dim SavePath As String = "C:\temp\" If IsNothing(filMyFile.PostedFile) = False Then Try Dim PostedFile = filMyFile.PostedFile Dim FileName As String = PostedFile.FileName Dim ContentType As String = PostedFile.ContentType Dim ContentLength As Integer = PostedFile.ContentLength PostedFile.SaveAs(SavePath & FileName) Message.Text = PostedFile.FileName & "Uploaded" & _ "
    Content Type: " & ContentType & _ "
    Content Length: " & ContentLength.ToString Catch ex As Exception Message.Text = "Failed To upload File" & ex.Source & ex.Message End Try End If Error msg : mscorlib Exception has been thrown by the target of an envocation. can someone please help me out. Thanks in advance

    Mohinder Singh

    N V 2 Replies Last reply
    0
    • V vengaqua

      i am doing this for uploding the file in the specified directory. But it gives error after the line which i have bolded. Dim SavePath As String = "C:\temp\" If IsNothing(filMyFile.PostedFile) = False Then Try Dim PostedFile = filMyFile.PostedFile Dim FileName As String = PostedFile.FileName Dim ContentType As String = PostedFile.ContentType Dim ContentLength As Integer = PostedFile.ContentLength PostedFile.SaveAs(SavePath & FileName) Message.Text = PostedFile.FileName & "Uploaded" & _ "
      Content Type: " & ContentType & _ "
      Content Length: " & ContentLength.ToString Catch ex As Exception Message.Text = "Failed To upload File" & ex.Source & ex.Message End Try End If Error msg : mscorlib Exception has been thrown by the target of an envocation. can someone please help me out. Thanks in advance

      Mohinder Singh

      N Offline
      N Offline
      nyogeswar
      wrote on last edited by
      #2

      have you tried PostedFile.SaveAs(@SavePath & FileName) Yogesh

      V 1 Reply Last reply
      0
      • V vengaqua

        i am doing this for uploding the file in the specified directory. But it gives error after the line which i have bolded. Dim SavePath As String = "C:\temp\" If IsNothing(filMyFile.PostedFile) = False Then Try Dim PostedFile = filMyFile.PostedFile Dim FileName As String = PostedFile.FileName Dim ContentType As String = PostedFile.ContentType Dim ContentLength As Integer = PostedFile.ContentLength PostedFile.SaveAs(SavePath & FileName) Message.Text = PostedFile.FileName & "Uploaded" & _ "
        Content Type: " & ContentType & _ "
        Content Length: " & ContentLength.ToString Catch ex As Exception Message.Text = "Failed To upload File" & ex.Source & ex.Message End Try End If Error msg : mscorlib Exception has been thrown by the target of an envocation. can someone please help me out. Thanks in advance

        Mohinder Singh

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        I think, you don't have the permission to save the file to the specified location ("C:\temp\"). Set write permission to IUSR_YOURMACHINENAME user to that folder. If you still have the same problem, post the complete StackTrace information. The Error Message you posted is not sufficient to debug the Error.

        Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

        V 3 Replies Last reply
        0
        • V Venkatesh Mookkan

          I think, you don't have the permission to save the file to the specified location ("C:\temp\"). Set write permission to IUSR_YOURMACHINENAME user to that folder. If you still have the same problem, post the complete StackTrace information. The Error Message you posted is not sufficient to debug the Error.

          Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

          V Offline
          V Offline
          vengaqua
          wrote on last edited by
          #4

          Complete stacktrace information: at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Microsoft.VisualBasic.CompilerServices.LateBinding.FastCall(Object o, MethodBase method, ParameterInfo[] Parameters, Object[] args, Type objType, IReflect objIReflect) at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn) at Microsoft.VisualBasic.CompilerServices.LateBinding.LateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack) at WebsiteLogix.Personal_Resource.Upload_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\WebsiteLogix\Personal Resource.aspx.vb:line 70

          Mohinder Singh

          1 Reply Last reply
          0
          • N nyogeswar

            have you tried PostedFile.SaveAs(@SavePath & FileName) Yogesh

            V Offline
            V Offline
            vengaqua
            wrote on last edited by
            #5

            it says invalid character.

            Mohinder Singh

            1 Reply Last reply
            0
            • V Venkatesh Mookkan

              I think, you don't have the permission to save the file to the specified location ("C:\temp\"). Set write permission to IUSR_YOURMACHINENAME user to that folder. If you still have the same problem, post the complete StackTrace information. The Error Message you posted is not sufficient to debug the Error.

              Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

              V Offline
              V Offline
              vengaqua
              wrote on last edited by
              #6

              inner exception: System.NotSupportedException: The given path's format is not supported. at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) at System.Security.Util.StringExpressionSet.AddExpressions(String[] str, Boolean checkForDuplicates, Boolean needFullPath) at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at System.Web.HttpPostedFile.SaveAs(String filename)

              Mohinder Singh

              1 Reply Last reply
              0
              • V Venkatesh Mookkan

                I think, you don't have the permission to save the file to the specified location ("C:\temp\"). Set write permission to IUSR_YOURMACHINENAME user to that folder. If you still have the same problem, post the complete StackTrace information. The Error Message you posted is not sufficient to debug the Error.

                Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group

                V Offline
                V Offline
                vengaqua
                wrote on last edited by
                #7

                how to set write permission to the particular user.

                Mohinder Singh

                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