Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27052

VS 2010 Open two files, copy all bytes from the second file to the first file at an offset..?

$
0
0
I'm making a program to help me with my interest in importing maps into games.

Pretty simple really. What I want is, the program to open the first file (where the maps will be imported), then to open a second file (map) and copy all bytes from that file to a specified offset in the first file.

I'm basically writing random codes to try to get this to work as I'm still pretty new to the advanced part of VB. I can't figure out how to make the program do what I want it do.

Here is my code so far:

Code:

Public Class Form1
    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
        Close()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, MenuItem2.Click
        OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        MenuItem3.Enabled = True
        Button2.Enabled = True
        ComboBox1.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, MenuItem3.Click
        Dim fs1 As New IO.FileStream("Maps.ex5", IO.FileMode.Open, IO.FileAccess.ReadWrite)
        Dim fs2 As New IO.FileStream(OpenFileDialog1.FileName, IO.FileMode.Open, IO.FileAccess.Read)
        fs2.Read(0, &H30, 5) -was just messing with random code here.
        fs1.Close()
        fs1.Dispose()
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

As you can see in that code, I have the program read the first file from a location, and then read the second file from the openfiledialog. How can I make it so it opens both files through different openfiledialogs? I ran into some errors doing this.


Thanks, MS-47

Viewing all articles
Browse latest Browse all 27052

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>