Quantcast
Viewing all articles
Browse latest Browse all 27046

VS 2010 [RESOLVED] overwrite file and if overwrite erorr show message box

Ok here is what i want..

i want a file to overwrite. And if the file that needs to be over written is opened or in use, i want my program to display a message box saying to close it when that file is in use, so my program can overwrite the file.

Here is My Code,,
All It Do So far Is Overwrite a file in my local drive using a resource file and display some text in richtextbox when its overwriting.

Code:

  Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim ipw As New IO.MemoryStream(My.Resources.boo) 'the resource file
        Dim qyi As IO.FileStream = IO.File.OpenWrite("C:\Programfiles\boo2u\boo.exe") 'here it is the file to be overwritten
        ipw.WriteTo(qyi)
        qyi.Close()
        RichTextBox1.Visible = False
        System.Threading.Thread.Sleep(1000)
        RichTextBox2.Text = "Starting it...." & "" & vbCrLf
        RichTextBox2.AppendText("File Patched Sucessfully !!")
    End Sub

Any Help To Make This Will Be Much Appriciated.
Sorry For My Bad EngLish
Thanks in Advance :)

Viewing all articles
Browse latest Browse all 27046

Trending Articles