Solved

Trying to learn C#

Posted on 2011-03-09
3
241 Views
Last Modified: 2012-08-13
What would be the equivalent of a vb6 Module in C# and how would the code below appear in C#.

strFileName = Dir("\\CAKPOSSERVER\C\POSiTrack\FTP\POS*.TXT")
What would be comparable to Open "\\CAKPOSSERVER\C\POSiTrack\FTP\" & strFileName for input as #1 in vb6
Line Input #1, textLineIn

I have several text files that I must iterate through and parse the text from each one using I suppose the substring function.

Thanks in advance!!

Jerry
0
Comment
Question by:JDL129
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 125 total points
ID: 35086414
There is no equivalent of a module in C#, everything is a class, but you can use static methods which allow you to call a class method without having to create an instance of the class.

To read a file line by line you would use something like:
StreamReader reader = new StreamReader("path to your file");
string line = string.Empty;

while ((line = reader.ReadLine()) != null)
{
     // parse the line
}

reader.Close();

Open in new window

0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 35086510
>>  What would be comparable to Open "\\CAKPOSSERVER\C\POSiTrack\FTP\" & strFileName

For the concatenation part, use System.IO.Path.Combine().

e.g.
using Sytem.IO;

string strFilename = "someFile.txt";

strFilename = Path.Combine("\\CAKPOSSERVER\C\POSiTrack\FTP\", strFilename);

Open in new window

0
 

Author Closing Comment

by:JDL129
ID: 35086578
Thanks to both of you for the response!!!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Hide vba in gp 7 48
C# Application Local DB Connection String 23 61
Check my code out(2) 1 35
bulid json format 3 21
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

19 Experts available now in Live!

Get 1:1 Help Now