Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Converting C sharp to Vb.Net

Posted on 2004-10-26
2
Medium Priority
?
339 Views
Last Modified: 2007-12-19
I am mainly confussed with the *****'s if some one could please convert and explain the marked parts please?

The int part in **1**
The buffer in **2**
The encbuffer in **3**
The buffer2 in **4**

Thanks in advanced.

-Tim

private void Encrypt()
            {
                  try
                  {
                        GoToBusyMode();
                        progressBar.Minimum=0;
                        System.IO.FileInfo finfo=new System.IO.FileInfo(inFile);
**1**                        progressBar.Maximum=(int)(finfo.Length/32);
                        lblStatus.Text="Encrypting...";

                        System.IO.FileStream fout=System.IO.File.Open(outFile,System.IO.FileMode.Create,System.IO.FileAccess.Write,System.IO.FileShare.Write);
                        System.IO.FileStream fin=System.IO.File.Open(inFile,System.IO.FileMode.Open,System.IO.FileAccess.Read,System.IO.FileShare.Read);
**2**                        byte []buffer=new byte[32];
**3**                        byte []encbuffer=new byte[32];
                        int c=0;
*****                        while((c=fin.Read(buffer,0,32))>0)
*****                        {
*****                              if(c!=buffer.Length)
*****                              {
*****                                    byte[]buffer2=new byte[c];
*****                                    for(int i=0;i<c;i++)
**4**                                          buffer2[i]=buffer[i];
*****                                    encbuffer=rsa.Encrypt(buffer2,false);
*****                                    fout.Write(encbuffer,0,encbuffer.Length);
*****                              }
*****                              else
*****                              {
*****                                    encbuffer=rsa.Encrypt(buffer,false);
*****                                    fout.Write(encbuffer,0,encbuffer.Length);
*****                              }
                              progressBar.Increment(1);
                        }
                        fin.Close();
                        fout.Close();
                        lblStatus.Text="Encryption successful";
                        GoToReadyMode();
                  }
                  catch(Exception ex)
                  {
                        MessageBox.Show("Error:"+ex.Message);
                        thread.Abort();
                        GoToReadyMode();
                  }
            }
0
Comment
Question by:timmyzx7r
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 300 total points
ID: 12412936
This is the result of passing the code through the utility at:
http://www.developerfusion.com/utilities/convertcsharptovb.aspx

Private Sub Encrypt()
 Try
   GoToBusyMode()
   progressBar.Minimum = 0
   Dim finfo As System.IO.FileInfo = New System.IO.FileInfo (inFile)
   progressBar.Maximum = CType((finfo.Length / 32), Integer)
   lblStatus.Text = "Encrypting..."
   Dim fout As System.IO.FileStream = System.IO.File.Open(outFile, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Write)
   Dim fin As System.IO.FileStream = System.IO.File.Open(inFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)
   Dim buffer(32) As Byte
   Dim encbuffer(32) As Byte
   Dim c As Integer = 0
   While (c = fin.Read(buffer, 0, 32)) > 0
     If Not (c = buffer.Length) Then
       Dim buffer2(c) As Byte
       Dim i As Integer = 0
       While i < c
         buffer2(i) = buffer(i)
         i += 1
       End While
       encbuffer = rsa.Encrypt(buffer2, False)
       fout.Write(encbuffer, 0, encbuffer.Length)
     Else
       encbuffer = rsa.Encrypt(buffer, False)
       fout.Write(encbuffer, 0, encbuffer.Length)
     End If
     progressBar.Increment(1)
   End While
   fin.Close()
   fout.Close()
   lblStatus.Text = "Encryption successful"
   GoToReadyMode()
 Catch ex As Exception
   MessageBox.Show("Error:" + ex.Message)
   thread.Abort()
   GoToReadyMode()
 End Try
End Sub
0
 

Author Comment

by:timmyzx7r
ID: 12412991
Thanks,  I found this site but it did not work correclty.

http://www.kamalpatel.net/ConvertCSharp2VB.aspx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

596 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question