I'm trying to incorporate .PadRight into my program. I want to make sure each text line is 574 bytes long. I've tried several things, including some suggestions from here. Below is my code. I get the following error when I uncomment the bolded line below, but the console.write works. I'm sure this is something small or stupid. Also please excuse all the extraneous garbage in the pgm right now.
Error 1 'string' does not contain a definition for 'padright' and no extension method 'padright' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
Error 1 'string' does not contain a definition for 'padright' and no extension method 'padright' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
Code:
using System.IO;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ReformatDEERs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void reformatButton_Click(object sender, EventArgs e)
{
string fileLine = "";
string newLine ="";
long all_records=0;
int shorty_records=0;
ulong[] rec_len = new ulong[574];
if (openFileDialog1.ShowDialog()==DialogResult.OK)
{
string name= openFileDialog1.FileName;
FileInfo fileI = new FileInfo(name);
// StreamReader fileSR = new StreamReader(file.opentext(name));
StreamReader fileSR = new StreamReader(@"g:\bruce\f\deers\a.txt");
fileLine = fileSR.ReadLine();
while(/*fileLine!=null*/ all_records < 300)
{
if (fileLine.Length < 574)
{
shorty_records = shorty_records +1;
Console.Write(fileLine.PadRight(600));
[b] // newLine = fileLine.padright(574);
[/b] }
all_records += 1;
rec_len[(fileLine.Length-1)] += 1;
fileLine=fileSR.ReadLine();
}
}
MessageBox.Show("Count = " + all_records,"ALL RECORDS");
MessageBox.Show("Shorties = " + shorty_records,"Short Dudes");
}
}
}