|
Take a look at WMI -- you can access it with script (VBScript, JScript, Python, Ruby, etc.) or even directly from C# with a little interop. Check out Scriptomatic[^] and look around that same vicinity of TechNet for more WMI information.
Matt Gerrans
|
|
|
|
|
i need to create a 'window dialog' in .showdialog() for user data input.
i can made it using window form or a component, but i've to do a choose.
What is better?
|
|
|
|
|
How can i count the number of lines in a string also the number of bytes in a string?
|
|
|
|
|
The number of lines in a string is the number of occurrences of Environment.NewLine + 1 . As the string class does not contain a method to count substrings you would probably have to run a for-loop over each char in the string and count.
The number of bytes of a string should be string.Length * sizeof(char) .
|
|
|
|
|
To Count line in string
Regex rx=new Regex(Environment.NewLine);
MatchCollection mc=rx.Matches(textBox1.Text);
int lineCount=mc.Count;
Note:if the last two chars of string is not Environment.Newline
the line count will be decreased by 1 so you can check
that last two chars in the string is Environment.NewLine
If not add it
To Get the bytes in string use Encoding class
and select Encoding Format you work with
For Example
int cb=Encoding.UTF8.GetByteCount(textBox1.Text);
MCAD
-- modified at 9:40 Saturday 27th August, 2005
|
|
|
|
|
Just to make publicity... :-P
Some files can be Mac and Linux files, and they can have different "NewLines"... Look at this program I made, get the source code if you want!
http://www.sulfurmidis.com/sulfursoft/software/tfc.html[^]
Darth_Sulfur (Sulfurik)
http://www.sulfurmidis.com
http://www.sulfursoft.tk
ftp://tsfc.ath.cx
http://tsfc.ath.cx
hotline://tsfc.ath.cx
|
|
|
|
|
The easiest way of counting the number of line breaks would be to remove them from the string and then check the difference in size:
lines = 1 + ((Len(text) - Len(text.Replace(Environment.NewLine, string.Empty))) / Len(Environment.NewLine));
---
b { font-weight: normal; }
-- modified at 11:28 Saturday 27th August, 2005
|
|
|
|
|
To read the number of bytes, you can use Systm.Text.Encoding.Default.GetByteCount .
The most accurate way to count lines would probably be to use StringReader.ReadLine , but if that's too much overhead, try this function:
static int LineCount(string str)
{
int lines = 1;
for(int i = 0; i < str.Length; i++)
{
if(str[i] == '\r' || str[i] == '\n')
{
if(i+1 < str.Length && (str[i] == '\r' && str[i+1] == '\n'))
i++;
lines++;
}
}
return lines;
}
-- modified at 19:13 Monday 29th August, 2005
|
|
|
|
|
hi,
how can i read information from a excel table...for example i want to read the row A1 and to write another value back....
any idea to do that?
bye
|
|
|
|
|
|
hi, i compiled this sample!
and i got that error:
private Excel.Application ExcelObj = null;
error CS0246: The type or namespace name 'Excel' could not be found (are you missing a using directive or an assembly reference?)
but the Interop.Excel Assembly = icrosoft Excel 11.0 Object Library is in the projekt!! hmmm...
cu
|
|
|
|
|
I've made a little application for opening pictures using pictureboxes. I've used File Type Editor to connect my app with .bmp. .jpg, . gif etc. file types. After instalation, when I doubleclick a picture file, my app runs, but there is no picture in pictureBox1. I know I have to do something with Arguments property, but I dont know what. I've tried:
public static void Main(string[] args)
{
Application.Run(new Form1());
args=Environment.GetCommandLineArgs();
foreach (string arg in args)
{
fajl=fajl+arg;
}
pictureBox1.Image=Image.FromFile(fajl);
}
How to make doubleclicked file apear in pictureBox1??
please help!
|
|
|
|
|
The line after Application.Run(new Form1()); will not be executed untill you close the form.You should put your code either in Form1 constructor or in form_load event handler or in form_activate event handler
for example:
public static void Main(string[] args)
{
Application.Run(new Form1(args));
}
private Form1(string[] args)
{
foreach(string arg in args)
fajl+=arg;
pictureBox1.Image=Image.FromFile(fajl);
}
P.S. remember that Form1 constructor is an instance member (not a classifier) then none of the variables within it can be static or you should use Form1.variableName to refer to them.
|
|
|
|
|
Thank you, thank you, thank you
It works perfectly now ;);)
|
|
|
|
|
I have an Visual C#.NET 2003 and want to develop a "Smart Device Application", but it isn't contained in the New Project dialog.
I've also installed:
.NET Compact Framework
Microsoft Pocket PC 2003 SDK
Mobile Application Development Toolkit
But I'm still not able to create that mysterious "Smart Device Application"
If I have some TOO CHEAP edition of VS IDE, is there some alternative IDEs which support mobile development?
|
|
|
|
|
Hi,
I would like to have a Web Update feature to enable a desktop app to update over the web.
Does anyone have any ideas/samples on how to do this?
I would like to check and download only the files that have changed.
Thanks in advance
Stephen McAllister
|
|
|
|
|
Hi Buddy,
I am also looking same kind of thing please if you found any hel regarding this please inform me.
Muhamad Waqas Butt
waqasb4all@yahoo.com
-- modified at 10:41 Saturday 27th August, 2005
|
|
|
|
|
|
does anybody know how to find all reference types of given object and set them all to null state, so given object can be available for GC?
for example..
object _a = new object();
object _b = _a;
now we have two reference type objects which are pointing to the same memory block.
the thing is that I don't know anything about "_a" and would like to set it to null state somehow from "_b".
what do you think?
luke
|
|
|
|
|
|
hi leppie,
thank you fast reply.
how would you set NULL state for those 2 references if you know only one of them?
luke
|
|
|
|
|
You can't. There is no backward reference from the object to it's references.
This sounds like the all too common situation where someone tries to fix bad programming with some magic command. You just have to keep track of your references.
---
b { font-weight: normal; }
|
|
|
|
|
thanks. ok, i'll just keep the track
|
|
|
|
|
This sounds like the all too common situation where someone tries to fix bad programming with some magic command. You just have to keep track of your references.
I was thinking that this sounds like the all too common situation where someone tries to fix bad programming with even worse programming.
Why in the heck would you want to null out references about which you know nothing? Just for the pleasure of seeing those lovely unhandled NullReferenceExceptions ? (Okay, I suppose that would provide a first step in tracking down those references that you couldn't find, but the OP didn't say that was the goal (if it was, mock objects would probably be a better solution anyhow)).
Matt Gerrans
|
|
|
|
|
I have noticed that I need not put any DLLImport statements in Windows application if I am using some DLLs. I just need to add those DLLs in the reference and then use it.
My question is when is it necessary to have a DLLImport statement in my C# code?
Thanks and Regards,
Amit
|
|
|
|