Uploading a File contents

Discussion in 'MCSD' started by =?Utf-8?B?UGFwcmlfQ2hha3Jhdm9ydHk=?=, May 19, 2004.

  1. Hello

    I am preparing for MCSD exams (vb.Net), and have a question to ask about a file being uploaded

    I am following the instructions ofMCSD - self paced training kit

    The code is as follow
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
    Dim strFileName As Strin

    Tr

    'get the file nam
    strFileName = filUpLoad.PostedFile.FileNam


    'exit if no file name was entere
    If strFileName = "" Then Retur
    'if file has zero length (did not exist on client

    If filUpLoad.PostedFile.ContentLength = 0 The
    lblMsg.Text = "file not found on client or contains no data.
    Retur
    End I

    ' get the base name for the file (exclude path)
    strFileName = System.IO.Path.GetFileName(strFileName
    'save uploaded file to serve
    filUpLoad.PostedFile.SaveAs(Request.MapPath("C:\papri") &
    "\" & strFileName
    'add file to list of server file
    lstServerFiles.Items.Add(strFileName
    'select an item in the list
    lstServerFiles.SelectedIndex =

    Catch ex As System.UnauthorizedAccessExceptio
    lblMsg.Text = "You ust set the permissions on the server " &
    "to allow the ASPNET user to write to the destination folder.
    Catch ex As Exceptio
    lblMsg.Text = "An unexpected error occurred " & ex.Messag
    Finall
    End Tr
    End Su

    I do not know why it comes up with the error "An unexpected error occurred "

    Can you also let me know please, how to debug an application
    so that i can walk every step to see where it is going wrong like in vb

    Many Thank
    Papri
     
    =?Utf-8?B?UGFwcmlfQ2hha3Jhdm9ydHk=?=, May 19, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?UGFwcmlfQ2hha3Jhdm9ydHk=?=

    Paul Robson Guest

    Papri_Chakravorty wrote:

    > Hello,
    >
    > I am preparing for MCSD exams (vb.Net), and have a question to ask
    > about a file being uploaded.
    >
    > I am following the instructions ofMCSD - self paced training kit.
    >


    There is something else you have to set in the page directive for
    uploading -
    EncType=multipart/form-data I think ....
     
    Paul Robson, May 19, 2004
    #2
    1. Advertising

  3. >Can you also let me know please, how to debug an application ?
    >so that i can walk every step to see where it is going wrong like in vb ?


    Debugging in ASP.NET is same as in the other types of apps, but you must set
    startup project and startup page and start the APP from debug menu (Right
    click on page in solution explorer and then clicking on Build and browse,
    won't start debugging).
    Regards,
    Daniel
     
    Daniel Joskovski, May 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timberwolf

    file contents printing

    Timberwolf, Dec 11, 2004, in forum: Computer Support
    Replies:
    5
    Views:
    502
    Toolman Tim
    Dec 12, 2004
  2. Lee Davison

    Winrar File - Creating contents list

    Lee Davison, Jan 25, 2005, in forum: Computer Support
    Replies:
    2
    Views:
    1,816
  3. Harry Da Hat

    Uploading George Preddy's File

    Harry Da Hat, Nov 13, 2003, in forum: Digital Photography
    Replies:
    90
    Views:
    1,755
    George Preddy
    Nov 21, 2003
  4. philbo30
    Replies:
    1
    Views:
    407
  5. Srividya Koduri
    Replies:
    0
    Views:
    1,100
    Srividya Koduri
    May 4, 2010
Loading...

Share This Page