Using VB in a Web application - Attempting to use the FormClosing Event for first time RRS feed

  • Question

  • I am attempting to use the Form Closing Event for the first time so please excuse.

    In my research I came upon this example code to copy a file from a web application to the client PC.

    Dim FileToCopy As String
        Dim NewCopy As String
        FileToCopy = "\\SERVER-NAME\c$\file.txt"
        NewCopy = "c:\file.txt"
        If System.IO.File.Exists(FileToCopy) = True Then
            System.IO.File.Copy(FileToCopy, NewCopy, True)
        End If
        Shell("notepad.exe " & NewCopy, AppWinStyle.NormalFocus, False, -1)

    The comment states IF YOU PUT THE CODE IN THE FORM CLOSING EVENT IT WILL COPY TO TEXT FRIL FROM THE SERVER TO THE CLIENT AND OPEN IT IN NOTEPAD.  My problem is I have never used a form closing event.  How do I code it and how do I called the form closing event.  When I code the following I get an error on closing

    Private Sub Form1_Closing(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles MyBase.closing
        End Sub


    (1)  How do I code a form closing event?

    (2)  How do I call the form closing event?


    Wednesday, February 15, 2017 7:08 PM

All replies

  • Your example copies a file from network file server not a webserver.  What specifically do you want to do?
    Wednesday, February 15, 2017 9:43 PM