Solved

Any one Help me I want to convert vb code  to c# code

Posted on 2007-11-14
3
253 Views
Last Modified: 2010-04-15
Public Sub loadUrl()
        Dim oFSO As FileSystemObject

        Set oFSO = New FileSystemObject
        Set propFile = oFSO.OpenTextFile(App.Path & "\sfa.properties", 1)

        'Read motoURL from sfa.properties file.
        If (propFile.AtEndOfStream <> True) Then
            strurl = propFile.ReadLine
            mypos = InStr(1, strurl, "=", 1)
            motoURL = Mid(strurl, mypos + 1, Len(strurl) - mypos)
        End If
        If motoURL = "" Then
             Err.Number = 1
             Err.description = "Error in the properties file. Value for motoURL is not mentioned or is invalid"
             Err.Source = "loadUrl"
             Call checkErrors(Err.description)
             Exit Sub
        End If

       
    End Sub
0
Comment
Question by:sitg
3 Comments
 
LVL 16

Accepted Solution

by:
gnoon earned 500 total points
ID: 20287371
private void loadUrl() {
  System.IO.StreamReader propFile = null;
  try {
    propFile = System.IO.File.OpenText("sfa.properties");
    string strurl = propFile.ReadLine();
    motoURL = strurl.Substring(strurl.IndexOf("=")+1);
  } catch(Exception e) {
    checkErrors("Error in the properties file. Value for motoURL is not mentioned or is invalid");
  } finally {
    if(propFile != null) propFile.Close();
  }
}
0
 
LVL 4

Expert Comment

by:rallsaldo
ID: 20288170
Hi,

This may be of help in future:

http://labs.developerfusion.co.uk/convert/vb-to-csharp.aspx

Cheers,
R
0
 

Author Comment

by:sitg
ID: 20310397
thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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