Upload exception!

Last post 08-11-2008 12:59 AM by thanhp. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 08-06-2008 7:16 AM

    • thanhp
    • Top 50 Contributor
    • Joined on 08-04-2008
    • Posts 9

    Upload exception!

    I am experiencing the upload method which throws an exception ("The following path is invalid: C:\Users\developer2\Desktop\Download\Pics\2.jpg") when I try to upload an image. Can anybody help me? Below is my snippet:

    Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click

    ' validation code goes here...

    Try

    UploadFile(txtAppKey.Text.Trim, txtAppName.Text.Trim, txtUsername.Text.Trim, txtPwd.Text.Trim, "/", New String() {"C:\Users\developer2\Desktop\Download\Pics\2.jpg"})

    lblStatus.Text = lblStatus.Text & "<br>" & "Upload complete!"

    Catch ex As Exception

    If TypeOf ex Is NirvanixException Then

    Dim NVNEx As NirvanixException = CType(ex, NirvanixException)

    lblStatus.Text = lblStatus.Text & "<br>" & "Code: " & NVNEx.ErrorCode & ControlChars.CrLf & "Message: " & NVNEx.Message

    Else

    lblStatus.Text = lblStatus.Text & "<br>" & ex.Message

    End If

    End Try

    End Select

    End Sub

    '*********************************************************************************************************************************

     Private Sub UploadFile(ByVal sAppKey As String, ByVal sAppName As String, ByVal sUsername As String, _

    ByVal sPwd As String, ByVal sRemotePath As String, ByVal sFilePath() As String)

    Try

    CurrentSession = New NirvanixSDK.Session(sAppKey, sUsername, sPwd, sAppName)

    objUploader = CurrentSession.GetFileUploader(sRemotePath)

    objUploader.UploadFiles(sFilePath)

    CurrentSession.Logout()

    Catch ex As Exception

    Throw ex

    End Try

    End Sub

  • 08-08-2008 7:56 AM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 614

    Re: Upload exception!

     I'm not sure what the issue could be, perhaps you can do something to ensure the path exists before you call upload.  You could try adding a file browse dialog so you know the path you are getting is correct as a test.

    Let me know if the problem still persists if you have verified the path.

    Regards,
         Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@msn.com
    Gmail: barryruffner@gmail.com
  • 08-08-2008 8:06 AM In reply to

    Re: Upload exception!

    in your upload method it looks like you are trying to pass a function as the file path:

    ByVal sFilePath() As String

     

    Life is a PHP script in need of debugging!
  • 08-11-2008 12:59 AM In reply to

    • thanhp
    • Top 50 Contributor
    • Joined on 08-04-2008
    • Posts 9

    Re: Upload exception!

    The path and the file are OK, but the problem was from Windows Vista. It seemed it didn't allow me to read the file from the above path, so when I moved the file to C:\temp\2.jpg, it worked.

    Thanks for your replies.

Page 1 of 1 (4 items)