Send file to server

Posted on 2005-05-16
Last Modified: 2010-04-23
VB.NET 2003 / WinAPP

I have implemented an OpenFileDialog so that the user can choose a file.  Files that will be choose are .DOC and .JPG and maybe a few other image file formats.

Anyhow, after they choose the file, the FULL LOCAL path gets dumped into a textbox.  How with the push of a button, send the local file, to a location on the fileserver?
Question by:chrisryhal
    LVL 2

    Author Comment

    BTW, this is all done via a mapped drive, or could use UNC if need be
    LVL 11

    Accepted Solution

    by using

    system.IO.File.Copy( sSource, sDest )

    dont forget permissions
    LVL 2

    Author Comment

    Ok, that worked out fine.  One quick thing though, if I want to rename the file with the code, how can I do so?  So, lets say the file is "Document1.doc" and for archiving purposes I need to rename it to a number.  Lets say "11122.doc"  is there a way to perform that action after the file has been copied, or declare it as that BEFORE its copied?

    Either way, thanks for the help
    LVL 11

    Expert Comment

    Yer just declare it as your copying it.

    dim sSource as string = "c:\temp.doc"
    dim sDest as string = "\\server\share\nuttyTemp.doc"   ' can be what ever you like. sSource, sDest )

    if you want the originaly file name heres a function to get it.
        Public Function GetFileName(ByVal File As String, Optional ByVal WithExtension As Boolean = True) As String
            Dim lPos As Integer

            lPos = InStrRev(File, "\")
            If (lPos > 0) Then
                GetFileName = Mid(File, lPos + 1)
                GetFileName = File
            End If

            If (WithExtension = False) Then
                GetFileName = Replace(GetFileName, "." & GetExtension(GetFileName), "")
            End If

        End Function

    Cheers CoopzZ

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Article by: jpaulino
    XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String ( Literal, only instead of starting and ending with w…
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 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

    14 Experts available now in Live!

    Get 1:1 Help Now