Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8844045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:23:17+00:00 2026-06-14T11:23:17+00:00

I need to convert a piece of code from VB to C#. what should

  • 0

I need to convert a piece of code from VB to C#. what should I use in place of FileSystemObject and TextStream?

what the below code does is that it reads a file already present in a directory and adds the content of the file to the fields.

Private Sub Read_abc_File()
    Dim FileSystem As FileSystemObject
    Dim abcFile As TextStream
    Dim abcLine As String, abcSection As String
    Dim abcFilename As String
    Const Read As Integer = 1

    abcFilename = "abc.txt"


    Set FileSystem = New FileSystemObject

    If Not FileSystem.FileExists(abcFilename) Then
        FileSystem = Null
        Exit Sub
    End If

    Set abcFile = FileSystem.OpenTextFile(abcFilename, Read, False)

    Do While abcFile.AtEndOfStream <> True
        abcLine = abcFile.ReadLine

        If abcLine > " " Then
            If Left$(abcLine, 1) = "[" Then
                abcSection = abcLine
            Else
                Select Case abcSection
                    Case "[Datafiles]"
                        DataFilename.AddItem abcLine
                    Case "[Locations]"
                        Location.AddItem abcLine
                    Case "[Formats]"
                        Format.AddItem abcLine
                    Case "[Categories]"
                        Category.AddItem abcLine
                End Select
            End If
        End If            
    Loop

    abcFile.Close
    Set abcFile = Nothing
    Set FileSystem = Nothing
End Sub

any suggestions/answers are appreciated.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:23:19+00:00Added an answer on June 14, 2026 at 11:23 am

    Heres a code snippet to get you started, i think you should be able to complete the job.

    using System;
    using System.IO;
    
    static void Main(string[] args)
    {
        string fileName = "abc.txt";
    
        if (!File.Exists(fileName))
            return;
    
        using (FileStream file = File.OpenRead(fileName))
        using (StreamReader reader = new StreamReader(file))
        {
            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
            }
        }
    }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sometimes I need to convert a piece of code or an entire project from
I need to convert a piece of code from Objective-C to Java, but I
I have a piece of code that needs to be run from a restricted
I have a piece of code in vb. I need to convert array of
I'm new to Elisp and I need to convert a piece of LaTeX code
I need to create a porting software that will convert Java code to C#
I have a piece of code that is written in C++ and need it
I wrote a piece of code in python that converts a raster file to
I need to convert full state name to its official state address code. For
I need to convert keys from type string to hash. The name of all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.