Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Trying to learn C#

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

618 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