renaming a file during saving for the file loader

Posted on 2011-10-17
Last Modified: 2012-05-12
I want to rename my file during saving for the file loader. below is the code i am using

If d_FileToUpload.HasFile Then
                    If d_FileToUpload.PostedFile.ContentLength > 4000000 Then
                        Exit Sub
                    End If
                    d_FileToUpload.SaveAs(Server.MapPath("docs\" & d_FileToUpload.FileName))
               Catch ex As Exception
                End Try
             End If
Question by:Anthony Matovu
    LVL 83

    Expert Comment

    Change this line

    d_FileToUpload.SaveAs(Server.MapPath("docs\" & d_FileToUpload.FileName))


    LVL 83

    Accepted Solution

    Did you get the point? If you want to add extension of the original file then

    d_FileToUpload.SaveAs(Server.MapPath("docs\MyName" & IO.Path.GetExtension(d_FileToUpload.FileName)))

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    This video discusses moving either the default database or any database to a new volume.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now