• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

DOS Commands In Visual Basic

Here is what I get:

Capture001110.jpg
 
You might be able to just do:
Properties.Resources.name_of_resource
 
Doh, looked at C# when I thought I was looking at VB. :laugh: This should work (finally):
My.Resources.resource_name
 
Hmm...

Capture003.jpg


But the file is clearly a member of resources... very strange.
 
Go into Project Properties, Resources, and click on the resource. Make sure the name is correct there and also Persistence should be "Embedded in .resx"
 
Go into Project Properties, Resources, and click on the resource. Make sure the name is correct there and also Persistence should be "Embedded in .resx"

That helped, the resource says it was added, but it was not. Glad that is sorted out now... Now another issue in the same area...

Capture004001.jpg
 
Last edited:
Your mediaplayer needs be given a byte array instead of an URL to the file. I don't know what mediaplayer is declared as so I can't be of much assistance there.
 
Your mediaplayer needs be given a byte array instead of an URL to the file. I don't know what mediaplayer is declared as so I can't be of much assistance there.

Fair enough! Thanks for your help! I will figure out another time how to play embedded midi files... Final Version is attached!

In other news, started a new program, and it is done, but a small issue has been encountered.

Code:
Public Class rarfinder

    Dim fdlg1 As OpenFileDialog = New OpenFileDialog()

    Private Sub btnchoose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnchoose.Click
        'File browser
        Dim fdlg1 As OpenFileDialog = New OpenFileDialog()
        fdlg1.Title = "Choose a File"
        fdlg1.InitialDirectory = "c:\"
        fdlg1.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
        fdlg1.FilterIndex = 2
        fdlg1.RestoreDirectory = True
        If fdlg1.ShowDialog() = DialogResult.OK Then
            txtfile.Text = fdlg1.FileName
            safetxtfile.Text = fdlg1.SafeFileName
        End If
        My.Computer.FileSystem.CopyFile(txtfile.Text, txtfile.Text & "_cpt")
        My.Computer.FileSystem.RenameFile(txtfile.Text & "_cpt", safetxtfile.Text & ".txt")
        btnscan.Enabled = 1
        btnchoose.Enabled = 0
    End Sub

    Private Sub btnscan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnscan.Click

        Me.txtdump.Multiline = True
        txtdump.Text = My.Computer.FileSystem.ReadAllText(txtfile.Text & ".txt")
        My.Computer.FileSystem.DeleteFile(txtfile.Text & ".txt")


        If txtdump.Text.Contains("rar") Then

            MsgBox("Rar Detected!")

        Else

            MsgBox("No Rar Found!")

        End If
        'Me.txtdump.Clear()
        btnchoose.Enabled = 1
        btnscan.Enabled = 0
    End Sub

    Private Sub cpfinder_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        btnscan.Enabled = 0
    End Sub
End Class

Long story short, the code works. Till it gets to the part where it looks in the text file. So the message box apparently does not store weird characters:

Capture007.jpg


As you can see, the textbox is incorrectly copying the data from the text file. Any ways to solve this so the data stays in a "raw" form?
 

Attachments

Here is the proof my program works, and that I need to figure out a way to get the raw data read.

Capture009.jpg
 
And getting closer... The first 4 characters are the same as in the text file, but the whole file did not show up... hmm...

Capture010.jpg
 
You need to use a BinaryReader/BinaryWriter, not a TextReader/TextWriter. Text is meant for for ASCII. ReadAll... is meant for small files. Binary is meant for binary files (RAR and JPG formats are binary).


What are you trying to achieve with this app? Detect RAR? lowercase or uppercase?
 
You need to use a BinaryReader/BinaryWriter, not a TextReader/TextWriter. Text is meant for for ASCII. ReadAll... is meant for small files. Binary is meant for binary files (RAR and JPG formats are binary).


What are you trying to achieve with this app? Detect RAR? lowercase or uppercase?

The app pretty much finds hidden RAR files. You know how you can combine a JPG and a RAR and it looks like an image still? Yeah well this will be able to tell you when a file is actually a hidden rar.
 
In that case, the attached file will help greatly. Add it to the project then do:

Code:
Dim results() As Integer = Search.Find("Rar", pathtofile, 4096, 1)
If results.Length > 0 Then
  // RAR found
Else
  // RAR not found
End If

It should be much faster than the way you are doing it now.


If it is a RAR file, "Rar" should be the first three bytes or 82, 92, 114.
 

Attachments

Hmm... I might try that later, but here is what I want to know now... If I can convert the text file I made to say, UTF-8 encoding, then I can read it in the text box. Is there any way I can do that with VB?
 
There's no point. JPG and RAR files offer very little legible text. They are binaries meant to be processed by machines, not man. XD


This would display it all (sort of) but I still wouldn't recommend it:
Code:
txtdump.Text = My.Computer.FileSystem.ReadAllText(txtfile.Text & ".txt", Encoding.UTF8)

Textboxes are not designed for more than 32 KiB of text.
 
Last edited:
There's no point. JPG and RAR files offer very little legible text. They are binaries meant to be processed by machines, not man. XD


This would display it all (sort of) but I still wouldn't recommend it:
Code:
txtdump.Text = My.Computer.FileSystem.ReadAllText(txtfile.Text & ".txt", Encoding.UTF8)

Textboxes are not designed for more than 32 KiB of text.

In rars, the phrase "rar" always appears, and that is my way of detecting them. So I have tried it your way above, no dice. But can I re-encode a .txt file in VB?
 
In rars, the phrase "rar" always appears, and that is my way of detecting them. So I have tried it your way above, no dice. But can I re-encode a .txt file in VB?
Remember, my code is case sensitive. If "rar" appears, it must be "rar," not "Rar." XD

The easiest way to handle text is via a StreamReader or StreamWriter.

Text files (*.txt) are ASCII. If you want to encode it, you'll need a heavier file format like RTF, DOC, or something else.
 
Regarding the "rar" vs "RAR" issue, well I have coded for that... or functions!

I am really trying to figure out how to re-encode a file in UTF-8 from Visual Basic. Is there any easy way to do that? I know they are ASCII, but VB seems not to like those... probably because I am using non-ASCII characters in the file.
 
Dim sr As New StreamReader("path to file", System.Text.Encoding.UTF-8)


Again, RAR files are binaries, not text. Less than 1% of the file is text and it is completely out of context when not processing all the encompassing binary data.
 
Back
Top