|
Yepp I've done it but It still can't run
The first I assign
textBox4.Text = reader.ReadLine.ToString();
but it said I used wrong method
so I change it to be
textBox4.Text = reader.ReadLine.();
It's no error
but can't use
I don't know why TwT
Message when it error
http://www.uppicth.com/show.php?filex=e5d4b8cd0fec144f140ded8bcbcfe23a.JPG[^]
modified on Thursday, April 30, 2009 6:15 AM
|
|
|
|
|
should be textBox4.Text = reader.ReadLine();
where are you using that thou? are you sure your not reading a null value?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
If you look closely at the code segement you posted:
yueru wrote:
string line = reader.ReadLine();
while (line != null)
{
string newLine = line.Replace("=", " ");
string[] vals = newLine.Split(' ');
line = reader.ReadLine();
}
textBox4.Text = reader.ReadLine();
reader.Close();
The problem becomes obvious, no?
When does it exit from the while loop?
How much of the file is left to be read into textBox4?
If you still can't see it, run it slowly through the debugger (sorry Luc) and it should be crystal clear.
Before you ask, no I won't correct your code. This is a basic error and you will learn better finding it yourself - you have all the clues and tools you need.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I know
|
|
|
|
|
|
Forget about Fixed length it's not my point
NOw I 've got the code
String inputfilename = "";
private void Add(){
StreamReader reader = new StreamReader(inputfilename);
string line = reader.ReadLine();
while (line != null)
{
string Date = line.Substring(12, 8);
if (line.Substring(11, 1) == "=")
{
string Time = line.Substring(21, 5);
string Linein = line.Substring(27, 10);
string Lineout = line.Substring(38, 1);
if ((string.Compare(Lineout, "0") > 0 || string.Compare(Lineout, "0") == 0) && (string.Compare(Lineout, "9") < 0 || string.Compare(Lineout, "9") == 0))
{
string Number = line.Substring(40, 20);
string Status = line.Substring(61, 3);
string Duration = line.Substring(65, 9);
string Cost = line.Substring(75, 3);
string Detail = line.Substring(79, 2);
string Network = line.Substring(82, 8);
string txtSQLQuery = "insert into par values('" + Date + "','" + Time + "','" + Linein + "','" + Lineout + "','" + Number + "','" + Status + "','" + Duration + "','" + Cost + "','" + Detail + "','" + Network + "')";
ExecuteQuery(txtSQLQuery);
textBox6.Text = textBox6.Text + "\r\n" + Date + " " + Time + " " + Linein + " " + Lineout + " " + Number + " ";
}
else
{
textBox5.Text = line + "\r\n" + textBox5.Text;
}
}
else
{
textBox5.Text = line + "\r\n" + textBox5.Text;
}
line = reader.ReadLine();
}
MessageBox.Show("End while loop");
}
thx for all comment +_!
|
|
|
|
|
Me, me, me, I do!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Quoting Sean Hederman from
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/b0d4cba1-471a-4260-94c1-fddd4244fa23/[^]
string sourceFileName = @"C:\VS2005 SP1.exe";
string destFileLocation = @"C:\";
int index = 0;
long maxFileSize = 52428800;
byte[] buffer = new byte[65536];
using (Stream source = File.OpenRead(sourceFileName))
{
while (source.Position < source.Length)
{
index++;
string newFileName = Path.Combine(destFileLocation, Path.GetFileNameWithoutExtension(sourceFileName));
newFileName += index.ToString() + Path.GetExtension(sourceFileName);
using (Stream destination = File.OpenWrite(newFileName))
{
while (destination.Position < maxFileSize)
{
int bytes = source.Read(buffer, 0, (int) Math.Min(maxFileSize, buffer.Length));
destination.Write(buffer, 0, bytes);
if (bytes < Math.Min(maxFileSize, buffer.Length))
{
break;
}
}
}
}
}
Vasudevan Deepak Kumar
Personal Homepage Tech Gossips
The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep!
|
|
|
|
|
Thank you for a example for multiple textfile
So do u have example about split ?
Thank you in advance
|
|
|
|
|
I will try to resume all answers in the following steps
1. Open file that you want to parse
2. Use StreamReader to read the file
3. Read line using StreamReader.ReadLine();
4. If Step 3 has data, continue to next step, other wise go to step 9
5. from result in above step replace all unnecessary characters with space, in your sample data replace "==" and '=' to space
6. split result from step 5 using method [yourstring].split in your sample use space as split character
7. post result from step 6 to database
8. repeat step 3 until 7
9. close your StreamReader
10. if there are errors occurred after you doing all steps, ask about them to this forum and read correlated documentations you need
happy coding...
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
I have created simple Web serivce using C# for adding two integers and saved the file with "MyWebService.ASMX". I have copied this file to Inetpub/wwwroot IIS directory. When I call this service in browser(http://localhost/Webservices/Addservice.asmx), I am able to see the text boxes for entering the numbers and I am able to see the result in XML.
I just write the file and even I didn't compile it, but I am able to use it. Probaly it's a dumb quesiton, I am new to .Net programming. Could somebody explain what is the program flow when I call the service from browser?
|
|
|
|
|
Siva Koyi wrote: I just write the file and even I didn't compile it, but I am able to use it.
It is compiled on fly. You can precompile it if required.
Siva Koyi wrote: Could somebody explain what is the program flow when I call the service from browser?
It will work only from your local system. If you try to access the web service from outside through browser, I guess you will not get the Invoke button.
|
|
|
|
|
Thanks for yor reply. You are right, I am not able to access for outside what is the reason?
and where the actual complilation happnes whether in Webserver or Browser(embeded with CLR)
Tankful if you could explain the execution flow?
|
|
|
|
|
Siva Koyi wrote: whether in Webserver or Browser(embeded with CLR)
It happens in the web server. Read this[^] to get an idea about what is happening. Also if you are developing web services which will be deployed to a public server, make sure you secure it. Easy way is to disable anonymous access. Web service consumers has to provide the credentials when they use it.
|
|
|
|
|
You can precompile trough desktop project too
I give you example how you can compile trough webservice and desktop application
Webserive ::
on the service.cs
[WebMethod]
public int sum (int a , int b)
{
return a + b;
}
and now run the webservice on local host there you will see input textbox1 and input textbox 2 then invoke button you will see the result on xml page
Compile trough desktop applicacion :
public partial class Form1 : Form
{
applicationname.Service ws = new localhost.applicacionname.Service(); // this conect you to webservice but dont forget to add web reference (which display you when you will run the webservice)
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e) // make button on your form and put three txtbox //
{
int a = int.Parse(textBox2.Text);
int b = int.Parse(textBox3.Text);
int result= ws.sum(a, b);
textBox4.Text = result.ToString();
}
Hope it will help you , good luck
|
|
|
|
|
It will be compiled and executed on runtime.
Either you love IT or leave IT...
|
|
|
|
|
I got CPU usage of each process using API but i can't do it with threads.
How can i get cpu usage of each thread using API and c#?
|
|
|
|
|
This is example of Thread.
CODE:
static void Main(string[] args)
{
Thread t1 = new Thread(new ThreadStart(Thread1));
Thread t2 = new Thread(new ThreadStart(Thread2));
t1.Priority = ThreadPriority.BelowNormal ;
t2.Priority = ThreadPriority.Lowest ;
t1.Start();
t2.Start();
}
public static void Thread1()
{
for (int i = 1; i < 1000; i++)
{
dosth();
Console.Write("1");
}
}
public static void Thread2()
{
for (int i = 0; i < 1000; i++)
{
dosth();
Console.Write("2");
}
}
public static void dosth()
{
for (int j = 0; j < 10000000; j++)
{
int a=15;
a = a*a*a*a;
}
}
|
|
|
|
|
|
Has anyone worked with the System.ComponentModel.ICollectionView in winforms NOT WPF. ?
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
|
Thanks 4 your reply. but i specific said NO WPF.
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
What for you want to know that?
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
hmm well for startes, how its used, and if I can implement it, so on, and so forth...
With great code, comes great complexity, so keep it simple stupid...
|
|
|
|
|
I got VS2005 C# source code which was in Source safe (PVCS) previously and i want to unbind it with PVCS. I have TFS on my machine which will be further be used for this purpose.
How can i do this by manually editing the files which keeps information about binding?
I tried deleting GlobalSection(SourceCodeControl) from .sln file but if i save the changes of the file then i am able to open it further in VS IDE.
What should i do OR what else i need to do to complete the process?
Thaks in Advance.
Gajesh
|
|
|
|