|
You can use WMI to obtain the amount of physical RAM by adding a reference to the System.Management namespace.
You would query the Win32_PhysicalMemory provider.
A quick search on CodeProject showed this article: http://www.codeproject.com/cs/system/GetHardwareInformation.asp
I'm sure that forcing GC on all processes is impossible as not all applications are managed.
I however look forward to reading any other comments.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Hi,
I am working on a Windows based project in Visual Studio.net.
1) I would like to store some documents (like Word, Excel, PPT) in SQL server 2000 and
2) Then show its shortcut as shown in a desktop in a listview.
3) When we click on that shortcut the file should open.
Can somebody please help me with the above 3 scenarios.
-- modified at 1:43 Monday 2nd April, 2007
|
|
|
|
|
1. http://support.microsoft.com/?kbid=258038
2. http://msdn.microsoft.com/msdnmag/issues/1100/c/
3. look to 1., just reassemble the file and run it.
http://www.codeproject.com/csharp/UseProcess.asp
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Hello everyone,
I have a Temparary Text file which is created when the user runs the Windows Application. I also would like to delete this file once the user closes the Windows Application.
Can someone be kind enough to tell me where I need to place the code to remove the file?
File.Delete("theTextFile.txt");
Thank you very much for your help and have a great weekend.
Khoramdin
|
|
|
|
|
If it's a Form based application, you can do this by overriding the OnClosing or OnClosed methods and putting the file deletion code there.
|
|
|
|
|
Hello to all!
i am new to c# and we are required to process the text files, minimum size of 35.4 GB. The tasks we want to acheive are
a. Make the file consistent - by removing unwanted 'return' chars
b. Generate the XML file
c. Load the data in XML file to database (MS SQL Server 2005)
the problem we are facing is, the process is taking massive amount of time, i.e. more than 1 hour to process just 500 MB of the file!!
currently we are just going through the file char by char, and checking if it is a data or '/r' or '/n', which definitly is not the best way to read such huge file...
so, we will definitly like to know the possible ways/techniques with which we can reduce the processing time.
the following is the code we are currently using:
while (read_from_file.EndOfStream != true)
{
read_from_file.ReadBlock(readfile, 0, 1);
temp = readfile[0].ToString();
if (!IsAlphaNumeric(temp) && readfile[0] != '-' && readfile[0] != '_')
{
if (temp == " ")
{
if (token == match_word && first_line_check>1)
{
write_to_file.WriteLine();
write_to_file.Write(token);
}
else
{
write_to_file.Write(token);
}
write_to_file.Write(" ");
token = null;
}
else if (readfile[0] == '\n')
{
write_to_file.Write(token);
write_to_file.Write(" ");
token = null;
}
}
else
{
token = token + temp;
}
}
in code, the variable "match_word" is the data before which we require the new line to be started, '/r' and '/n' at any other place are invalid and must be removed.
also, will "threads" and "reading text file in byte instead of char" be helpful and increase the speed of processing? and will the threaded code will be able to keep the data in same sequence??
and how much can we reduce the processing time?
Thanks in advance
Adeel
|
|
|
|
|
madeelch1986 wrote: read_from_file.ReadBlock(readfile, 0, 1);
You read from disk char by char? I think reading larger chunks of data at once should be faster. Then again there is probably some caching in TextReader/stream/disc or so, so experiment a bit and measure performance might be good idea.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Thankyou very much....ya i was thinking of experimenting with threads and reading in bytes rather than in chars....but the 1st experiment did it all....the solution from "Guffa" made the process completed in less than 20 MINUTES on the same 35 GB file!!!!!
|
|
|
|
|
dnh wrote: You read from disk char by char? I think reading larger chunks of data at once should be faster
Actually there is underlying caching.
Anyway, without any doubt, OP's code is by no means optimal.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
I am not surprised that the code takes a lot of time to run. You are creating one or two strings for every character you read, so to process a 500 MB file, you will have created about 1000 million string objects.
If you want to remove all line breaks and put line breaks before the keywork, why not simply:
string line;
string newLineMatchWord = "\r\n" + matchWord;
while ((line = inputReader.ReadLine()) != null) {
outputWriter.Write(line.Replace(matchWord, newLineMatchWord));
}
The Replace method returns a reference to the same string if no change was made, so it will only create a new string for lines that actually contain the keyword.
If the file can start with the keyword, you have to add some code to handle that before the loop. As this occurs only once, it should definitely be handled in separate code before the loop, and not inside the loop.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thankyou very much for the great reply!!!! the process was completed in just a bit less than 20 minutes on the same 35 GB file!!! Thanks
|
|
|
|
|
Nice. It's not every day you see a 20000% performance improvement.
---
single minded; short sighted; long gone;
|
|
|
|
|
Good job, Guffa, but there are to much zeros in your improvement calculation.
|
|
|
|
|
Sorry, % did the trick.
|
|
|
|
|
hi guys ,, i got some problem , i have a windows application in C# which contains some win forms,
but in the properties of this project i dont see any object to make it startup object,,
my forms are not seen in startup object drop down in the project properties > application tag >
- startup object drop down.
thanks in advance
hello
|
|
|
|
|
If your using VS2005 look at the program.cs file it contains something like the following;
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
If you look at the Run statement you you'll see here that I'm running form Form1 replace this with the name of the form you want to run at startup.
Prior to VS2005 each form that is elligible for startup will have just the run statement in Main
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
Hope this helps
Mike
You can do anything you want but you pay for everything you do!
|
|
|
|
|
Hello friends need help here..
Before this I have learn to create password validating form.Which is user have to key in password to enter another form. The password is default that have set in the coding.Now I need help how to connect to MY Sql database from C# from and compare the password that already I set in MY Sql database,table name Security and Field name password and the password is "ABCD".I dont know how to use SQL server 2005.
Below are the coding for the first form that validate to enter to form2.
//////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace cubaan1
{
public partial class Form1 : Form
{
Form2 form1 = new Form2();
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.PasswordChar = '*'; //Masking Char
textBox1.MaxLength = 14;//Max Length is 14
}
private void button1_Click(object sender, EventArgs e)
{
string strDefaultPassword = "security"; //Keep the default password
string strEnteredPassword = textBox1.Text;
if (strEnteredPassword == strDefaultPassword)
{
this.Hide();
form1.ShowDialog();
}
else
{
MessageBox.Show("Wrong password entered");
this.Close();
}
}
}
}
//////////////////////////////////////////////////////////
How to change this to connect to MY Sql Database and compare the password from the database.
Tq in advance......
|
|
|
|
|
CLASSES:student PROPERTIES :string name,string grade,string studentid,string surname METHODS:Add(string lessonCode, int point),grade showGrades(string lessonCode)
CLASS:grade PROPERTIES:String lessonCode,int point METHODS:
CLASS:reg PROPERTIES:int NumberOfRegs METHODS:AddStudent(student stu),RemoveStudent(string studentid),student ShowStudent(string studentid)
these are the classes,properties and methods that i have to use...
*students names,surnames,studentid and grades will be stored
*if any of the fields name,surname or grades if blank the registration wont be done
*for every student grades can be added
*studentid cant be changed,we can see the number of students,and we can call the students by their studentid
THATs all i need..i tried so hard but coludnt find a solution..
THX for your helps
|
|
|
|
|
Please don't start multiple threads on the same subject.
There is a modify link on your original post if you need to change your post.
Personally, I don't see that this post is any better than the last.
Please read my relpy to your original message.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
View my Blog
|
|
|
|
|
Make a start on your homework, when you get stuck we'll help you. But we won't do your homework for you. It would be unfair on you, even although by helping you with your homework you get the answer without learning anything it makes my job more secure.
So, some hints to get you started.
You have been given a list of classes, their properties and methods. Those are stubs that you can start writing. Then you just have to fill in the blanks.
|
|
|
|
|
yvzhn! this is Professor Ulhas from ur university.
when I saw u posted ur homeworx on the cpian web sights, i knew who u were. I told teh students never ever to post homoworks on the csexian webpags. now i see your failings i must felunks you in the highest orders. i have a doubt about your future life as soon i must curse you wit shiva devils for ur cheatings. infiinite melancholy! here is ur cursings!
vil humo ∑ﮗ shivna bar shiva ₣♂ un ulum ☺Ҝ♠ж dar niftu! ∑ ۞
sad curses
Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas
|
|
|
|
|
CLASSES PROPERTIES METHODS
student string Name grade Add(string lessonCode, int point)
grade ShowNotes(string lessonCode)
string studentid
grade [] grades
string Surname
grade String lessonCode
int Point
reg int NumberOfRegs AddStudent(student stu)
RemoveStudent(string studentid)
student ShowStudent(string studentid)
these are the classes,properties and methods that i have to use...
*students names,surnames,studentid and grades will be stored
*if any of the fields name,surname or grades if blank the registration wont be done
*for every student grades can be added
*studentid cant be changed,we can see the number of students,and we can call the students by their studentid
THATs all i need..i tried so hard but coludnt find a solution..
THX for your helps
|
|
|
|
|
|
If you really tried so hard, then you should be able to present at least the tiniest little bit of input from yourself, and not just pasting in the homework assignment.
There are a lot of people here that can give you useful hints, but for that you have to present what you have done, and where you are stuck.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello! I've made a animation of ball, flying on the form, from the edge to edge. But i've put a PictureBox,and the ball isn't seen anymore. It is flying in the backwards of my picttureBox. I've tryed to BringToTheBack the pictureBox, but it is not working. What should i do?
One nation - underground
|
|
|
|