|
Apologies in advance that may not be a C# issue, but perhaps .NET, NTFS, XP-SP2 or even hardware. You tell me.
I have sucessffuly ran breath-first and depth-first versions of the following C# snippet on different hardware as a precursor to noodling around with databases, SQLite, etc. Seems simple enough. Makes 1M diretcories as in D:dataset/II/JJ/KK where II, JJ, and KK are are 100 nodes each. On my developmemt machine (xp-sp2, 2GB, stable) I have this repeatable condition where when I get to about i = 67 (670K dirs created) the program slows down and then the system becomes unresponsive enough that I must reboot! No chance to use the VS debugger.
I quick format the D: drive before each operation, so the dir construction in this program is being performed on a clean FS with a new MFT. I watch the memory usage (doesn't use much). I've monitored the heap (doesn't use much). I'm perplexed with this system-specific issue; as it is one of the few times (for me) that a user-space program has caused so much trouble. Thoughs on what to try next appreacited. Or pointers to a more appropriate forum. (Yes, I know I should try/catch a possible exception at CreateDirectory; I doubt that is the issue). Thanks!
namespace make_dir_tree
{
class Program
{
static void Main(string[] args)
{
string path;
Stopwatch watch = new Stopwatch();
watch.Start();
for (int i = 0; i < 100; i++)
for (int j = 0; j < 100; j++)
{
for (int k = 0; k < 100; k++)
{
path = String.Format("D:/dataset/{0:D2}/{1:D2}/{2:D2}", i, j, k);
Directory.CreateDirectory(path);
}
Console.WriteLine("i:{0} j:{1}",i,j);
}
watch.Stop();
Console.WriteLine("Elapsed: {0}", watch.Elapsed);
Console.WriteLine("In milliseconds: {0}", watch.ElapsedMilliseconds);
}
}
}
|
|
|
|
|
Hi,
you MUST use try-catch for operations that MIGHT fail due to external circumstances,
since they WILL fail sooner or later.
How big is your D: drive ?
In your case, my best guess (and the try-catch would have shown you already) is
your D: drive is full. Each directory takes at least one cluster, cluster size depends
on partition size, but is at least one sector (normally 0.5KB).
When the disk is full, you get an IOException. I dont know what you did not to get it,
maybe running in a separate thread ??
|
|
|
|
|
OK, I'll add the try/catch around the CreateDirectory, and report back
It shouldn't fail, but it could.
In this case the D drive is a "just formated" 1TB drive with nothing else on it.
This 1M node directory structure usually takes about 1 GB in NTFS.
-ss42
|
|
|
|
|
NTFS issue. When you create a file or folder, it has to create a unique 8.3 format name ('short name') for compatibility with 16-bit DOS and Windows applications. It has to search the directory to ensure that it is unique, which takes longer the more files you have in the folder. It works best if you have distinguishing information at the beginning of the filename so that there are few clashes.
You can disable this feature globally in Windows by setting the following key
[HKEY_LOCAL_MACHINE\SYSTEM\CURRENTCONTROLSET\CONTROL\FileSystem\Ntfs]
"Disable8dot3NameCreation"=dword:1 However, you should only do this on systems used for a fixed purpose and with careful testing.
|
|
|
|
|
In my project i am using a data grid. I have have one button to delete records(rows) in the Grid. If i drag the mouse accross the rows on the grid, it selects all the rows. when clicked delete button it deletes the pointed record.
Is there any facility to restrict the user from selecting multiple rows or what event fired when user select multiple rows?
|
|
|
|
|
Hi Guys,
I want to know how can I detect that the internet connection on my machine is idle.
Can you hint me with any code snippet, .net class or something like that
Thanks in advance
Mahmoud Zidan myBlog[^]
|
|
|
|
|
hope this will give an Idea.
SSK.
|
|
|
|
|
|
I've been trying to find out about this process for a while now and am getting nowhere. Is there anyway to do this using Directsound? While looking at DirectX.Capture it seems to me that it will save the sound everytime, which I don't want.The reason I am needing this is to make a guitar tuner program and so need to be able to extract the pitch of the sound in real time.
Any help is appreiciated
Thanks
|
|
|
|
|
if you want to do pitch extraction then you have to resort mathematics to solve this problem, i.e Fourier Transform. Back in the 70s Lawrence Rabiner published a paper in pitch extraction. You can follow his algorithm to extract the pitch or formants of a sound wave and its pretty easy to implment in c# or vb .net since I have done it using Matlab. If you google hard enough you should be able to find it, it was published in one of the IEEE journals.
Over the weekend if I find my research paper I will add the details on to this post.
|
|
|
|
|
well i did manage to figure out the algorithm I had used, it wasnt by Rabiner but by Markel. Markel wrote the paper, "The SIFT Algorithm, For Fundamental Frequency Estimation" and was published in the IEEE Transactions on Audio and Electoracoustics. SIFT stands for The Simple Inverse Filtering Technique. The paper was published in 1976, so a long time ago. I wrote the code in Matlab just by reading the paper and it was pretty easy.
However, I was more interested in determining the gender of the voicing recording any performing pitch analysis. The actual accuracy of determination of the pitch was handled by a second algorithm component. I had used two algorithms MLE, Maximum Likelihood Estimation and MAP, Maximum A Posteriori. Refer to Numerical Receipies in C pdf book to get implementation details for MLE and MAP.
I dont know how appealing this maybe but its an alternative to DirectX but a bit too mathematically challenging.
|
|
|
|
|
Thanks very much, I'll look into SIFT and see how that goes.
|
|
|
|
|
hello all,
in my database i took empid ,username,password, status,usertype
for status =1 is for admin
status=2 for normal user
in my code it doesn't work
please see my code
depends on status my page goes to that page.
<pre>
SqlConnection con= new SqlConnection ("uid=sa; password=sa123; database=usermanagement; server=c113");
SqlCommand cmd=new SqlCommand ("select * from tbl_user_management",con);
SqlDataReader dr;
con.Open ();
dr=cmd.ExecuteReader ();
con .Close ();
Lbluser .Text ="";
Lblpassword .Text ="";
Txtusername .Text ="username";
Txtpassword .Text ="password";
int status;
//status= dr["status"];
//int status;
status=Convert.ToInt32(1);
if(status==1)
{
//status=Convert.ToInt32 ("1");
Response .Redirect ("admin.aspx");
}
else if (status==2)
{
//status=Convert.ToInt32 ("2");
Response .Redirect ("Welcome.aspx");
}
srinivas
|
|
|
|
|
srinivassam wrote: int status;
//status= dr["status"];
//int status;
status=Convert.ToInt32(1);
Erhm, it looks like you're converting 1 to the declared integer 'status'... This makes everyone an admin :->
|
|
|
|
|
srinivassam wrote: status=Convert.ToInt32(1);
if(status==1)
{
What should that be?
All the best,
Martin
|
|
|
|
|
Hi,
How many records has your database and how do you know you have the proper row?
I would do it something like this:
<br />
String connection = "uid=sa; password=sa123; database=usermanagement; server=c113";<br />
<br />
SqlConnection con= new SqlConnection (connection);<br />
SqlCommand cmd=new SqlCommand ("select * from tbl_user_management where username ='" + txtUsername.Text + "'",con);
<br />
SqlDataReader dr;<br />
con.Open ();<br />
dr=cmd.ExecuteReader ();<br />
<br />
if (dr.HasRows())<br />
{<br />
if (dr.Read())<br />
{<br />
Lbluser.Text = String.Empty;<br />
Lblpassword.Text =String.Empty;<br />
Txtusername.Text ="username";<br />
Txtpassword.Text ="password"; <br />
int status = Convert.ToInt32(dr["status"].ToString());<br />
}<br />
}<br />
con.Close();<br />
switch (status)<br />
{<br />
case 1: Response .Redirect ("admin.aspx"); break;<br />
case 2: Response .Redirect ("Welcome.aspx"); break<br />
default: break;
}<br />
<br />
|
|
|
|
|
hi friend thankyou very much
now its working
thanks for your help
earlier i got errors but i solved now it is working fine
thank you
srinivas
|
|
|
|
|
Hi,
How do you run an application under different credentials?
I have created a small app which accesses active directory. One of its tasks is to move objects. However only admin credentials can move object as i wish to. I need to run my c# windows app under this username and password so that i can move these objects.
Thanks
Steve
|
|
|
|
|
|
Hello all ,
I am tring to bind the listbox control to a database table.
I am trying to do this using a thread.
But i am not succeeded yet. Please help me i am new to this threadign concept.
thanks in advance.
Bharath.S Ron
|
|
|
|
|
Don't double post your question...
|
|
|
|
|
PLease don't repost the question just because you didn't get the answer you are looking for.
The problem is that you cannot access a GUI object (like the listbox) from a different thread, other than the main application thread. You have to do an invoke back to the GUI thread for that. But if the binding itself is time-consuming, the Invoke will not help because you are again doing it on the GUI thread so your application will not respond during that period.
If you can isolate the time-consuming bit of the code, you can move that alone to a different thread and then Invoke back to the GUI thread when you are done.
Checkout this example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/scag-ch06.asp[^]
|
|
|
|
|
Hi,
I have a small problem.
In a gridview I want to read out cellValues. It regards the reading of cellValues after Editing.
My Method
<br />
public string giveCellValue(Object typeOfObject, GridView gv, Int32 rowNumber, Int32 cellNumber, Int32 controlNumber)<br />
{<br />
return ((typeOfObject)gv.Rows[rowNumber].Cells[cellNumber].Controls[controlNumber]).Text;<br />
}<br />
If I want to read out a textBox object I want to do:
String ReadValue = giveCellValue(TextBox, gridMyGrid, 1, 0, 0);
For a Label I want to do
String ReadValue = giveCellValue(Label, gridMyGrid, 1, 0, 0);
That is where .NET shoots me and says I cannot pass the object as a variable.
How to overcome this problem.
|
|
|
|
|
Hi,
if you define giveCellValue(TextBox myTextBox, ...) then it will accept any TextBox,
but it wont accept a Label.
if you define giveCellValue(Control myControl, ...) then it will accept a TextBox,
a Label, and all other Controls; now you can access myControl.Text since Text is a
property that exists for all Controls; but you still would not be able to access
a property that exists just for some Controls.
The better way however is to define giveCellValue(string text, ...)
and call it like so:
String ReadValue1 = giveCellValue(myTextBox.Text, gridMyGrid, 1, 0, 0);
String ReadValue2 = giveCellValue(myLabel.Text, gridMyGrid, 1, 0, 0);
Doing so giveCellValue does not have to touch other, independent, Controls at all.
It is better from OO perspective.
Hope this helps.
|
|
|
|
|
Hello everyone,
I am implementing a simple C# OLE DB Provider (C# COM Server). For C# (managed code), I am wondering what is the entry point (which coclass and which method), client will invoke at first?
It is clear if I write my own client, but I am confused about other clients which I do not have source codes, for example, if I use Microsoft Excel (as a client) to invoke my C# OLE DB Provider, which is the entry point? Any reference materials or debug tools?
thanks in advance,
George
|
|
|
|
|