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

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

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

        'Read motoURL from 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
Question by:sitg
LVL 16

Accepted Solution

gnoon earned 500 total points
ID: 20287371
private void loadUrl() {
  System.IO.StreamReader propFile = null;
  try {
    propFile = System.IO.File.OpenText("");
    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();

Expert Comment

ID: 20288170

This may be of help in future:


Author Comment

ID: 20310397

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now