Solved

Trying to learn C#

Posted on 2011-03-09
3
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

730 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