[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

Send file to server

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?
  • 2
  • 2
1 Solution
chrisryhalAuthor Commented:
BTW, this is all done via a mapped drive, or could use UNC if need be
by using

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

dont forget permissions
chrisryhalAuthor Commented:
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
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.

system.io.file.copy( 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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now