|
I know - this is a wierd one. I thought more about it straight after I posted but didn't edit the post at all because I wanted to see what the reaction was to confirm what I thought, or to flame me down!
Personally, I would never use ++ or -- on reference types. It's not that obvious how it will affect things. Those operators are about changing values so I keep them for structs only.
The main rule I leaned about operator overloading is if it's not 100% obvious what something will do and affect other objects - either document it very clearly or don't do it!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
I don't hold myself responsible for any post I make after 7 pm.
|
|
|
|
|
|
I try not to wake up before 10AM but sure, whatever
(Actually for this entire year so far I have been up at 6 on work days which sucks)
|
|
|
|
|
hi,
how i can create a 2d graph in c# like the performance graph in the task manager?
|
|
|
|
|
The Graphics class has some methods like DrawLine() that allow you draw shapes during run time.
You can get a Graphics object by using this.CreateGrahpics() or making one yourself and assigning to the form later with this.CreateGrahpics() .
If you use it with the correct values, I suppose you can make a performance graph.
Of course that's just the graph, to create the background simply us the BitMap class to read a file and then use the Graphics object's DrawImage() method to display it.
You should use double buffering, which simply means drawing to a bmp in memory and
whne it's done, drawing the content on a 2nd BitMap and passing that to the Graphics object.
You can try make it work with the other methods of the Graphics class, ike DrawRectangle() or FillRectangle() .
|
|
|
|
|
Try using ZedGraph[^]. It's pretty good and should give you more than enough.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I have a datagrid incliding: MedicineName, Contry, Quantity, .., Total.
When I want to type a word ( ex: "B" ) then appearing a list conntaint: "B1","B2","B6" ( note that "B1 B2 B6 " exist in list) then it allow to choose a item from the list. The list is disappeared and also that all has value which chosen.
Thank you very much!!
|
|
|
|
|
Hi
Is it possible to convert String var to String[]?
|
|
|
|
|
Putting the string as an array of that string?
string[] arr = new string[] { str };
Or splitting the string?
str.Split(' ');
Eslam Afifi
|
|
|
|
|
Hi
I used the following code to list all the folders in a given path:
Here sp is a string which contains the list of all the folders...
DirectoryInfo dire = new DirectoryInfo(sss);
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
FileInfo fil = new FileInfo(foldername);
sp = fil.ToString();
}
}
Now to list all the files in all folders contained in sp,is it right to
convert sp to string[] and proceed this way....it still gives me the files in
in only 1 folder
String[] gi = new String[] { sp };
foreach (String pil in gi)
{
DirectoryInfo di = new DirectoryInfo(pil);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(pil);
foreach (String filename in files)
{
FileInfo fil2 = new FileInfo(filename);
listBox2.Items.Add(fil2.ToString());
}
}
}
|
|
|
|
|
What you want to do exactly???
Do you want to display all the files name in the list control or folders Names??
|
|
|
|
|
Hi
I want to list all the folders in any drives and then the files
in each folder in a listbox control
I am able to list all the folders...
I tried with the following code to list the files in the folder
The folder contains 10 files but this code lists only 1 file from
that folder...The last foreach does not work properly...
What changes should i make?
private void ShowPath_Click(object sender, EventArgs e)
{
reader = new XmlTextReader("path.xml");
Form1 f = new Form1();
String sp="";
String[] gi;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
String s1;
s1 = reader.Value;
String ss = listBox1.SelectedItem.ToString();
String sss = ss + s1;
object o3 = (object)sss;
DirectoryInfo dire = new DirectoryInfo(sss);
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
FileInfo fil = new FileInfo(foldername);
sp = fil.ToString();
}
}
gi = new String[] { sp };
foreach(String pil in gi)
{
DirectoryInfo di = new DirectoryInfo(pil);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(pil);
foreach (String filename in files)
{
FileInfo fil2 = new FileInfo(filename);
listBox2.Items.Add(fil2.ToString());
}
}
}
break;
}
}
}
|
|
|
|
|
Are you using two list controls
one is for showing the list of folders and
the other for showing the list of files for selected folder from the folder list box??
|
|
|
|
|
Hi
I am using one listbox to list the drives in a system and a another
to list both the folders and the files..
I tried the same in 2 different listbox controls n that works well...
But my requirement is to list the files and folders in one listbox....
|
|
|
|
|
use following code which populates all the files and folder from the directory info path provided to this function
e.g call this function as
DirectoryInfo dirInfo = new DirectoryInfo(@"C:\");
GetAllDir(dirInfo);
.
.
.
private void GetAllDir(DirectoryInfo directory)
{
FileSystemInfo[] dirContents = directory.GetFileSystemInfos();
foreach (FileSystemInfo fileSysInfo in dirContents)
{
if (fileSysInfo.Attributes.Equals(FileAttributes.Directory))
{
this.listBox1.Items.Add(fileSysInfo.Name);
DirectoryInfo dirInfo = new DirectoryInfo(fileSysInfo.FullName);
GetAllDir(dirInfo);
}
else
{
this.listBox1.Items.Add(" - "+fileSysInfo.Name);
}
}
}
Hope this works for you!!!!!

|
|
|
|
|
Hi,
The above code will list the files only in C:\ drive...
If i want it for any other drive i should change it manually
in the code....
In my code i have listed all the drives in a listbox control so
that i can make a choice at the run time...
Can you give some suggestions about this?
|
|
|
|
|
in event handler of the liust where you have listed the drive
write this code
DirectoryInfo dri = new DirectoryInfo(listBox1.SelectedItem.ToString());
GetAllDir(dri);
|
|
|
|
|
I am in need of some help. I have written the following code to save entries in a datagrid to the database, my code looks like this:
UseWaitCursor = true;
this.Validate();
this.accountTypeBindingSource.EndEdit();
ServiceReference1.Service1Client proxySaveBankAccountTypes = new WBGTS.Client.ServiceReference1.Service1Client();
var bankAccountTypeChanges = (WBGTS.BusinessLogicLayer.dsWBGTS)this.dsWBGTS.GetChanges();
if (bankAccountTypeChanges != null)
{
if (proxySaveBankAccountTypes.SaveAccountType(ref bankAccountTypeChanges))
{
var bankAccountTypeRows = from row in this.dsWBGTS.AccountType
where Convert.ToBoolean(DataRowState.Added)
select bankAccountTypeChanges;
this.dsWBGTS.Merge(bankAccountTypeChanges);
this.dsWBGTS.AcceptChanges();
}
}
UseWaitCursor = false;
The problem is that when I add somthing to the datagrid it always shows the -1 number and the new record, after closing the form and opening again the record is fine but if you add a new entry it shows duplicates again!
I am trying to build a foreach loop into this method but I am having difficulty converting dataset to datarow.
Thanks!
Illegal Operation
|
|
|
|
|
Illegal Operation wrote: but I am having difficulty converting dataset to datarow.
A dataset is a collection of datatables. A datatable has a collection of datarows.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I have a simple batch file script here that runs during log on and log off that writes a rolling CSV file of each user and which computer they are on. Just for fun, here's what I am running...
LOG ON SCRIPT:
for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 "%computername%"') do set IP=%%i
rem The following line creates a rolling log file of usage by workstation
echo Log In: %TIME% %Date% %USERNAME% >>\\lsdnas3\Logs\Computers\%COMPUTERNAME%.log
rem The following line creates a rolling log file of usage by user
echo Log In: %TIME% %Date% %COMPUTERNAME% IP=%IP% >> \\lsdnas3\Logs\Users\%USERNAME%.log
LOG OFF SCRIPT:
for /f "Tokens=2 Delims=[]" %%i in ('ping -n 1 "%computername%"') do set IP=%%i
@rem The fololowing line creates a rolling log file of usage by workstation
@echo Log Off: %TIME% %Date% %USERNAME% >> \\SERVER\Logs\Computers\%COMPUTERNAME%.log
@rem The following line creates a rolling log file of usage by user
@echo Log Off: %TIME% %Date% %COMPUTERNAME% IP=%IP% >> \\SERVER\Logs\Users\%USERNAME%.log
Well, I want to first choose computer or user logs... Got that figured out (duh) but how do I get a dropdown that will list each file so I can open it as a data source and display it? I know how to open and read the files, and all that boring stuff.
I am sure I will figure it out via a bit of research, but I thought asking might help someone else looking for a similar solution in the future.
Matt
|
|
|
|
|
This won't compile, it's not valid C# code.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Oh I understand... This is a simple batch file for DOS (runs in Windows XP in our domain).
I write a lot of simple asp.net apps so I can use them anywhere in any of our locations... These log files were fabricated because we have a lot of users who bounce around from PC to PC and we want to be able to know where they are when they call or e-mail us.
I am writing an ASP.NET intranet site with C# and want to use C# to display what these batch files created. (I posted them above because I know batch files can be fun).
I thought it would be relevant since it is using a different method (other than C#) to start the process of logging.
|
|
|
|
|
For some reason I was expecting a story about cows.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
KnotBeer wrote: Well, I want to first choose computer or user logs... Got that figured out (duh) but how do I get a dropdown that will list each file so I can open it as a data source and display it? I know how to open and read the files, and all that boring stuff.
To get a list of files, you can use the [Directory.GetFiles^]. I believe this will work with UNC paths as well as local paths. To read the file as a data source you can look at [this^] article.
Hope that helps.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|