Results 1 to 6 of 6

Thread: How to send a notification to the user that the file is in use by another program

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2015
    Posts
    114

    How to send a notification to the user that the file is in use by another program

    How do you send a notification to the user that the program cannot Autosave a file, while it is in use on another program? It cannot be saved even if there is a timer on the program on the RichTextBox_TextChanged event(). Here is the function:

    Code:
    Private Sub AutosaveFile()
    
            Dim path As String = (My.Computer.FileSystem.SpecialDirectories.Desktop & "\Common-Mistakes-Backup.rtf")
     
                ' This text is added only once to the file.
                If File.Exists(path) = False Then
     
                Using fs As FileStream = File.Create(My.Computer.FileSystem.SpecialDirectories.Desktop & "\Common-Mistakes-Backup.rtf")
                    fs.Close()
                    ' Save the contents of the RichTextBox into the file.
                    RichTextBox1.SaveFile(path, RichTextBoxStreamType.RichText)
                    Timer1.Start()
    
                End Using
    
                End If
     
            Try
                ' Delete the file if it exists. 
                If File.Exists(path) = True Then
    
                    ' Save the contents of the RichTextBox into the file.
                        RichTextBox1.SaveFile(path, RichTextBoxStreamType.RichText)
    
                        Timer1.Start()
    
                End If
    
            Catch ex As Exception
                Console.WriteLine(ex.ToString())
            End Try
     
        End Sub
    Last edited by nqioweryuadfge; Jul 15th, 2016 at 09:19 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width