Click here to Skip to main content
15,895,256 members
Home / Discussions / C#
   

C#

 
GeneralRe: my drawing Moves?? Pin
xiaowenjie1-Nov-04 7:22
xiaowenjie1-Nov-04 7:22 
GeneralRe: my drawing Moves?? Pin
Charlie Williams1-Nov-04 10:07
Charlie Williams1-Nov-04 10:07 
GeneralRe: my drawing Moves?? Pin
xiaowenjie1-Nov-04 18:46
xiaowenjie1-Nov-04 18:46 
GeneralAccessing .NET Assemblies from COM+ Component Pin
perlmunger1-Nov-04 5:26
perlmunger1-Nov-04 5:26 
GeneralRe: Accessing .NET Assemblies from COM+ Component Pin
Alex Korchemniy1-Nov-04 8:30
Alex Korchemniy1-Nov-04 8:30 
GeneralRe: Accessing .NET Assemblies from COM+ Component Pin
perlmunger1-Nov-04 8:40
perlmunger1-Nov-04 8:40 
GeneralRe: Accessing .NET Assemblies from COM+ Component Pin
Alex Korchemniy1-Nov-04 8:45
Alex Korchemniy1-Nov-04 8:45 
GeneralStreamReader method (object.ReadLine()) Pin
Blubbo1-Nov-04 5:22
Blubbo1-Nov-04 5:22 
I've got this code and I am trying to understand on why I got the input string to be blank at the 3rd readline(). There is about 550 characters on a line with total of 25 lines in a hex file.

sample code below...

public int ReadFileControl()
{
string FN;
string inputString;
StreamReader input;
StreamWriter output;
StreamReader OutputHeaderTest;
int rowCount = 0;
bool header;
string FileName;

// create data source.... (for DataGrid in GUI - named "fdt")
DataTable fdt = new DataTable();
DataRow dr;
fdt.Columns.Add(new DataColumn("File Name", typeof(string)));
fdt.Columns.Add(new DataColumn("# data interpreted", typeof(int)));
InterpResultTable.DataSource = fdt;

OpenFileDialog ofp = new OpenFileDialog();
ofp.CheckPathExists = true;
ofp.CheckFileExists = true;
ofp.Multiselect = true;
ofp.Filter = "Hex files (*.hex)|*.hex|Txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
ofp.FilterIndex = 0;
ofp.DefaultExt = "hex";
DialogResult result = ofp.ShowDialog();
if (result == DialogResult.Cancel)
return 0;
for(int n = 0; n < ofp.FileNames.Length; n++)
{
header = true;
rowCount = 0;
FN = ofp.FileNames[n].Replace("hex", "txt");
FileName = FN.Substring(FN.LastIndexOf("\\")+1);
//input = new FileStream(ofp.FileNames[n], FileMode.Open, FileAccess.Read);
input = File.OpenText(ofp.FileNames[n]);

try
{
OutputHeaderTest = File.OpenText(FN);
if (OutputHeaderTest.ReadLine() != "")
header = false;
//if (OutputHeaderTest.Peek != "")
// header = false;
OutputHeaderTest.Close();
}
catch
{
}

output = File.AppendText(FN);

// Continue reading while there are still lines to be read
inputString = input.ReadLine();
while (inputString != null)
{
if (header)
{
output.WriteLine(InterpretMe(inputString, header, FileName.Substring(0, 3)));
header = false;
}
output.WriteLine(InterpretMe(inputString, header, FileName.Substring(0, 3)));
//output.Flush();
inputString = input.ReadLine();
rowCount++;
}

output.Close();
input.Close();
dr = fdt.NewRow();
dr[0] = FileName;
dr[1] = rowCount;
fdt.Rows.Add(dr);
}

return 1;
}

public string InterpretMe(string hexdata, bool header, string prefix)
{
// below is to load the dll file according to the hex filename,
// pass the string there, run the interpretation,
// then return the interpreted string.

try
{
String path = Application.StartupPath + "\\" + prefix + ".dll";
Assembly a = Assembly.LoadFrom(path);
Type mm = a.GetType(prefix);
object o = Activator.CreateInstance(mm);
object [] par = new object[] {hexdata, header};
return (mm.InvokeMember("InterpretCrumData", BindingFlags.Default | BindingFlags.InvokeMethod, null, o, par).ToString());
}
catch
{
MessageBox.Show("DLL failed");
}
return "unknown";
}
// end sample code

If there's any more question on this and I can explain more in details. Can anyone notice what my code has went wrong?
GeneralDateTime format Pin
goatstudio1-Nov-04 5:18
goatstudio1-Nov-04 5:18 
GeneralRe: DateTime format Pin
Dave Kreskowiak1-Nov-04 6:32
mveDave Kreskowiak1-Nov-04 6:32 
GeneralRe: DateTime format Pin
goatstudio2-Nov-04 17:15
goatstudio2-Nov-04 17:15 
QuestionHow to do this? Pin
momer1-Nov-04 5:04
momer1-Nov-04 5:04 
AnswerRe: How to do this? Pin
Blubbo1-Nov-04 6:30
Blubbo1-Nov-04 6:30 
GeneralRe: How to do this? Pin
momer1-Nov-04 6:46
momer1-Nov-04 6:46 
QuestionDenis Bauer's Site Is Down? Pin
Josh Koppang1-Nov-04 5:04
Josh Koppang1-Nov-04 5:04 
GeneralChanging Opacity of Parent Form/Window Pin
sommarafton1-Nov-04 4:47
sommarafton1-Nov-04 4:47 
GeneralRe: Changing Opacity of Parent Form/Window Pin
Alex Korchemniy1-Nov-04 8:01
Alex Korchemniy1-Nov-04 8:01 
QuestionHow to &quot;extract&quot; data from a web page? Pin
Member 14309891-Nov-04 4:44
Member 14309891-Nov-04 4:44 
AnswerRe: How to &quot;extract&quot; data from a web page? Pin
Alex Korchemniy1-Nov-04 7:51
Alex Korchemniy1-Nov-04 7:51 
QuestionHow to do this in C#? Pin
momer1-Nov-04 2:27
momer1-Nov-04 2:27 
AnswerRe: How to do this in C#? Pin
Judah Gabriel Himango1-Nov-04 4:14
sponsorJudah Gabriel Himango1-Nov-04 4:14 
GeneralRe: How to do this in C#? Pin
momer1-Nov-04 4:38
momer1-Nov-04 4:38 
GeneralRe: How to do this in C#? Pin
Judah Gabriel Himango1-Nov-04 5:15
sponsorJudah Gabriel Himango1-Nov-04 5:15 
GeneralRe: How to do this in C#? Pin
momer1-Nov-04 5:21
momer1-Nov-04 5:21 
GeneralProcess sql scripts Pin
totig1-Nov-04 2:21
totig1-Nov-04 2:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.