|
for example;
061_pmr_c0_txhb_cut_rxhb_to_smx.vl.GIF
|
|
|
|
|
Just open visual studio 2005 / latest
add
one button (to intiate click event ),
one textbox (contains expression you want to search ),
and one listbox to show the results
add click event on Button1 by double clicking on it and paste following code
//replace mine path with your own
DirectoryInfo DirInfo = new DirectoryInfo(@"F:\Documents and Settings\Administrator\My Documents\");
FileInfo[] DirFiles = DirInfo.GetFiles(textBox1.Text, SearchOption.AllDirectories);
listBox1.Items.Clear();
foreach (FileInfo FileObj in DirFiles)
{
listBox1.Items.Add(FileObj);
}
goto top of file and add a namespace >> using System.IO;
press F5 and run
insert expression to search. click on button. result will be displayed to list box.
if this doesnot work the provide me email address i will mail my project to you
|
|
|
|
|
Why you didn't use my code ? (The first Comment ?)
No offense , it's just a kind of discussion ...
thank you ...
I know nothing , I know nothing ...
|
|
|
|
|
Hello,
I tried many ways to do it (as you wrote and another ways) but in all of them it doesn't always find the file i need.
For example if the starting path is the immediate folder that contains the file it works fine and finds the file, but when the starting patch is a higher (maybe 2-3 folder upper) it doesn't find this file (i write exactly the same name).
It seems it doesn't enough time to the program to collect all the files names inside the folder. I did a little delay but it didn't help.
This is my code:
foreach (string d in Directory.GetDirectories(Start_dir))
{
if (!d.Contains("Shared Documents"))
{
System.Threading.Thread.Sleep(200);
foreach (string f in Directory.GetFiles(d))
{
//MessageBox.Show(f);
if (f.Contains(search))
{
Process.Start(f);
review_file_found = true;
return;
}
}
dirsearch(d, search);
}
}
|
|
|
|
|
Or it even seems as it doesn't have enough memory to do this search.
Because files (in directories) that are located in the "beginning of the list" it finds (and opens),
But files that are located a little "deeper" in the list he can't file and even the application get stucked in such situations
|
|
|
|
|
If there is way so i can send you the project
just replace the path, recompile, run the project. put expression and click on the button. list will be displayed. It is working on my PC.
|
|
|
|
|
OK,
You can send me it to michgr@nana.co.il
thanks very much
|
|
|
|
|
i have sent a mail also to you i was in hurry so without subject
|
|
|
|
|
OK thanks,
I will try it and let you know
|
|
|
|
|
Hi,
The code you sent me works fine, but very very slow. My code works much faster:
foreach (string d in Directory.GetDirectories(Start_dir))
{
if (!d.Contains("Shared Documents") && !d.Contains("Anna") && !d.Contains("CE Group") && !d.Contains("DEF") && !d.Contains("DtReport")
&& !d.Contains("images") && !d.Contains("Lists") && !d.Contains("MMGBD") && !d.Contains("Site") && !d.Contains("SP Requests")
&& !d.Contains("STAM") && !d.Contains("Training") && !d.Contains("uptest") && !d.Contains("X5") && !d.Contains("X8")
&& !d.Contains("Form") && !d.Contains("Yonah"))
{
//System.Threading.Thread.Sleep(200);
foreach (string f in Directory.GetFiles(d))
{
//System.Threading.Thread.Sleep(200);
//MessageBox.Show(f);
m=f.Replace("\\"+"\\moss.ger.ith.intel.com\\sites\\MPGBD-03\\HAL\\PD\\","");
//MessageBox.Show(m);
if (m.Contains(search1))
{
MessageBox.Show("found");
//System.Net.WebClient client = new WebClient();
//client.UseDefaultCredentials = true;
//client.DownloadFile(f, @"c:\\123.gif");
//Process.Start(@"c:\\123.gif");
//System.Threading.Thread.Sleep(500);
//Process.Start(f);
review_file_found = true;
return;
}
}
dirsearch(d, search1);
}
}
The problem is that with this code (with the messagebox.show("found")
it finds the file (the message appears).
But when i usethe process.start and try to open the file or even to download it it seems as it doesn't see the file at all (some files it sees and some not). It seems as it doesn't enter the if condition at all (even don't do the -
review_file_found=true
because outside this method i check the status of the bool and show a messagebox says the file not found. But the program does find it if i don't do the process.start
Maybe i need to use another way to open the file?
Here is an example of the file path:
\\moss.ger.ith.intel.com\sites\MPGBD-03\HAL\PD\Puma M Reviewd FIB edits\002_pumam_b0_flsh2.GIF
|
|
|
|
|
|
Help me to take sql server 2000 database backup using VS.net 2008 using
C# code.
|
|
|
|
|
0.33 seconds of google search gave me these [^]results
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi
This Code might help you.
we have to create 2 textbox 1 of name - dbName
textbox 2 of name - txtLocation
private void button1_Click(object sender, EventArgs e)
{
SqlCommand cmm = new SqlCommand();
SqlConnection cn = new SqlConnection("server=.;database=" + dbName.Text + ";user=sa;password=tiger123");
cn.Open();
cmm.CommandText = "BACKUP DATABASE " + dbName.Text + " TO DISK = N'" + txtLocation.Text + "\\Intermidiate_backup_200905291809.bak' WITH NOFORMAT, NOINIT, NAME = N'Intermidiate_backup_20090529180939', SKIP, REWIND, NOUNLOAD, STATS = 10";
cmm.CommandType = CommandType.Text;
cmm.Connection = cn;
cmm.ExecuteNonQuery();
}
Thanks & regards
Satish Pai B
|
|
|
|
|
public static void BackupDatabase(string DataBaseName , string Backupfile , string Description )
{
SqlCmd = new SqlCommand("BACKUP DATABASE @DataBaseName TO DISK = @Backupfilepath WITH INIT , DESCRIPTION = @Description", SqlCon);
SqlCmd.Parameters.AddWithValue("@DataBaseName", DataBaseName);
SqlCmd.Parameters.AddWithValue("@Backupfilepath", Backupfile);
SqlCmd.Parameters.AddWithValue("@Description", Description);
SqlCmd.ExecuteNonQuery();
}
I know nothing , I know nothing ...
|
|
|
|
|
In my application, I have a task which is running on a background thread. I need a notification in the background thread when ever a MessageBox or any modal dialog is displayed in the UI thread.
Though I can do it manually by calling some function before displaying the MessageBox, but it will be great if I dont have to.
For e.g.:
backgroundThread.MessageShown();
MessageBox.Show("Task halted!");
I am guessing there might me some message which can be hooked on to. Even in the main GUI thread, is there any message/event that get fired just before a modal dialog is shown?
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
Why should a task that runs on a worker thread need to know of it every time a message box is shown in the UI? This sounds strange to me. Perhaps there is a better way to do it, but only if you explain what you are trying to achieve.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Okay, here is the requirement. I have some tasks which are done on the UI thread, and I have to show progress on a separate dialog, which is been shown on a worker thread. I understand that it should be the tasks which must be done on worker thread, but the current scenario cannot be changed for the time being.
Every thing is working fine, except for one glitch - if a message box is shown in the UI thread, it gets hidden below the progress dialog. So the user never gets to know that UI is waiting for an input. I need a way to get notified that a modal dialog box has been shown and I should hide the progress dialog.
Right now, I have to hide it explicitly just before every call to MessageBox.
I hope that explains.
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
The NULL DeveloperI have some tasks which are done on the UI thread, and I have to show progress on a separate dialog, which is been shown on a worker thread.
This defeats the purpose of a worker thread (because it cannot happily do its work on the background), and defeats the purpose of having the main thread as an UI thread (which is a thread with a message pump and you have blocked it with some lengthy processing). Blocking the message pump is just atrocious.
The NULL DeveloperEvery thing is working fine, except for one glitch - if a message box is shown in the ...
No! The glitch is that you are blocking the application's message pump. Just please have the worker thread do the lengthy processing and let it also notify the UI of the progress.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh, I fully agree with you, as I had mentioned and as I had said, this scenario cannot be changed because these are already existing applications written that way. And that application is HUUUUUGE!
So I had to do it the other way.
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
I agree with the others that the design is flawed but you seem to be aware of that.
You could wrap the message box call into your own static method with the call to the backgroundThread and MessageBox.Show, and call your method instead each time.
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) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Dave, that will serve the purpose for MessageBox only. What about existing custom modal dialog boxes?
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
The NULL Developerand I have to show progress on a separate dialog, which is been shown on a worker thread
So you're saying that the progress dialog is launched by the background thread instead of the UI thread? If so, there's your problem. ALL UI, including the progress dialog should be created on the UI thread, not a background thread. You can invoke a method from the background thread to update the progress bar. If you can't change this, you're pretty much screwed. There is no notification your app is about to create a new dialog.
|
|
|
|
|
|
The CBT Hook is what would be looking for but it's a huge overkill solution to the problem of showing the window on the wrong thread in the first place.
|
|
|
|