?
Solved

Trying to learn C#

Posted on 2011-03-09
3
Medium Priority
?
257 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 500 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 75

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…
Suggested Courses

840 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