|
Hi everybody
How can find out number of characters in a file?
Best Regards,
Reza Shojaee
|
|
|
|
|
File.ReadAllBytes.Count, or something like that
You may be able to get it from the FileInfo class also.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Christian Graus wrote: File.ReadAllBytes.Count, or something like that
That'll work for ASCII and UTF-32, but not for UTF-8 and some other encodings with variable character length. File.ReadAllText(path).Length should work better.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Depends, if it's a text file or a binary file, and if he wants file size, or number of characters.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
using System.IO;
FileInfo info = new FileInfo("filename.txt");
long charCount = info.Length;
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
After spending the last few months reading about Test Driven Development I am a complete and utter believer. Unfortunately I'm still inexperienced and need advice on unit testing a class which incorporates a timer.
For example I am building an ActivityMonitor class which would be used to detect an activity timeout on a class (typically a mediator for a windows form) and reset it. I'm envisioning something like this:
ActivityMonitor
..private Timer _timer;
..private EventDelegate _timeout_callback;
..ActivityMonitor(EventDelegate callback, int timer_interval);
..public Reset();
How do I test something like TimeoutRaisesCallback? I could set the timer of course and wait for the callback but that would just slow down my unit tests. Do I merely set it to something very short like a few milliseconds and take the hit? Or is there a better standard way to handle this?
Also, suppose I have a class that uses the Activity Monitor:
ClassThatUsesActivityMonitor
..private ActivityMonitor _activity_monitor;
..ClassThatUsesActivityMonitor() {_activity_monitor = new ActivityMonitor(new EventDelegate(Reset));}
..public Reset();
..public DoSomething();
How do I go about unit testing that ClassThatUsesActivityMonitor reacts appropriately if the ActivityMonitor calls its Reset() function while DoSomething() is executing?
I look foreward to your responses, thank you very much,
Togakangaroo
|
|
|
|
|
umm...bump...not sure why I'm not getting a response
|
|
|
|
|
I doing the work on the C#.net 2005 Windows Application. In Windows Application their is control named web browser which is i used.
I want to get another data(Value) in the web browser where a data(Value) is already in it.i want to change the data(Value) dynamically(I mean update the webbrowser according to the click happend in the data grid view)? how can i done this? Please help me.
MURALEEKRISHNAN.K
|
|
|
|
|
This question didn't make sense last time you asked it. Did you bother to read the replies you got ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
so that i make clear the question which is i asked
MURALEEKRISHNAN.K
|
|
|
|
|
ItIf you have a datagrid, you have an ASP.NET website. This will run inside your web browser, how do you want to interact with it, in code ? You want to insert values ? OK, in that case, you need to access the HTML of the current page, parse it and modify it.
I found this with google:
http://bytes.com/forum/thread254118.html[^]
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I am writing a web app where I have a staff heirarchy, coaches, business manager, ect.
I have an area where you fill in contact information for these people, along with parents and any other contacts you may have.
I want to be able to have a button on one page that says "Choose Coach" for example, and it brings up the list of people I entered, lets me select one, and then save it.
I can do all the selecting and saving side of it. I don't know how to have that page come up and then page it back to the parent page.
I am using ASP.NET. Any ideas?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
so you didn't notice our ASP.NET forum ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
Hi there.
How can we collapse a node in treeView (WinForm) ?
Thank you.
|
|
|
|
|
Hi,
Please try this code snippet:
void CollapseTree(TreeNode ParentNode)
{
if(ParentNode.IsExpanded)
ParentNode.Toggle();
for(int i=ParentNode.Nodes.Count-1;i>=0;i--)
{
if(ParentNode.Nodes[i].Nodes.Count>0)
{
if(ParentNode.Nodes[i].IsExpanded)
ParentNode.Nodes[i].Toggle();
CollapseTree(ParentNode.Nodes[i])
}
}
}
For more details please visit the following link:
Article1[^]
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
So you used Toggle() method.
Thank you
|
|
|
|
|
Hello
1-i have a method of weather web service, but i do not know how using it in my client windows form.
URL:http://www.deeptraining.com/webservices/weather.asmx
2-I have a C# code about weather web service,but i do not know how using it in my server for making web service.
URL:http://barnamenevis.org/forum/showthread.php?t=47550&highlight=%D9%87%D9%88%D8%A7
thanks
|
|
|
|
|
Hello.
Well,here[^] there are many useful posts.
Why don't you use them ?
|
|
|
|
|
hello
I know them,but i do not know how using them.
I want help about them.
thank you
|
|
|
|
|
Hi there.
I have a code like this :
Regex.IsMatch("sth", textBoxSearchTxt.Text.Trim(), RegexOptions.IgnoreCase)
Thus I must extrude ESCAPE CHARACTERS from textBoxSearchTxt.Text
How can I do this by C#
As always thanks in advance.
modified on Monday, August 11, 2008 8:28 PM
|
|
|
|
|
Mohammad Dayyan wrote: Thus I must extrude ESCAPE CHARACTERS from textBoxSearchTxt.Text ( Like + * ( ) ... )
I am confused, + * ()... are not escape chars? what are you trying to exclude none alpha chars?
this RegEx will remove all except alpha-numeric.
string newString = Regex.Replace(oldString, "[^A-Za-z0-9]", "");
Yusuf
|
|
|
|
|
Oh, I'm sorry.
I mistook.
Yusuf wrote: string newString = Regex.Replace(oldString, "[^A-Za-z0-9]", "");
Thank you.
|
|
|
|
|
How do I get the current Date and Time in .NET fw.
Please let me know.
Thanks,
Happy Programming!
Regards,
ctrlnick !
|
|
|
|
|
Is this your purpose?
DateTime time = DateTime.Now;
Console.WriteLine(time);
Console.ReadKey();
|
|
|
|
|
You use DateTime.Now to get the current date and time on the local machine.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|