|
From what I remember the limit is 1,000 for the SOAP API but they're not creating new keys for it anymore (they were free). You can possibly create a local web-page and sign up for the AJAX query stuff to retrieve what you want, alternatively if you don't mind parsing HTML (just had a look at the format of the Google results page and it's pretty clean) you can just use a HttpWebRequest[^] object to form the request and retrieve stuff from that.
Have a search for Html Agility Kit which allows parsing of non-well formed html.
|
|
|
|
|
I have one form based program in VC#.
I found the following problem:
when I run it only one time, it takes only about 1 second.
but when I run it 20 times by using a loop, it takes far more than 1*20=20seconds, actually it takes even more than 100 seconds!
I think it may be because some memory or sources are not released during the loop. but I don't how to release the memory and sources for each loop.
I do hope some expert can give me some hints!
thank you very much!!
|
|
|
|
|
Post your loop code. I can't help you if I don't know what you are doing.
Simon
|
|
|
|
|
Hi,
the code is a little bit long, as follows:
simply speaking, I put several buttons in one panel, and each of them represents on function, then I just run the functions from the begining to the end.
private void toolStripButton_run_Click(object sender, EventArgs e)
{
Control[] control_panel = this.splitContainer1.Panel2.Controls.Find("panel_buffer", true);
DoubleBufferPanel double_panel = (DoubleBufferPanel)control_panel[0];
....
//////////////////////////////start normal simulaitons/////////////////////////////////////
this.toolStripStatusLabel_status.Text = "Overall simulation:";
this.toolStripStatusLabel_percent.Visible = true;
this.toolStripProgressBar1.Visible = true;
this.toolStripProgressBar1.Maximum = 10000;
textBox_simulation_output.Text += "Start the simulation ...";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += Environment.NewLine;
//Application.DoEvents();
//bool parameter indicate simulation is done normally
bool b_done = true;
//double parameter indicate the simulation time for one loop
double d_time_loop = 0;
if (b_stop == true)
{
b_done = false;
}
//start the simulation
if (b_stop == false)
{
// splitContainer1.Enabled = false;//disable the container1 during simulaiton
this.toolStripButton_stop.Enabled = true;//enable the stop button
this.stopSimulationToolStripMenuItem.Enabled = true;
if (b_user_loop == false)
{
loop1_max = 1;
loop2_max = 1;
loop3_max = 1;
}
int progress_n = 0;
int loop_count = 0;
for (int loop = 0; loop < loopmax; loop++)//for each loop
{
for (int loop1 = 0; loop1 < loop1_max; loop1++)
{
loop1_no = loop1;
for (int loop2 = 0; loop2 < loop2_max; loop2++)
{
loop2_no = loop2;
for (int loop3 = 0; loop3 < loop3_max; loop3++)
{
Stopwatch sw = new Stopwatch();//start to calculate
sw.Reset();
sw.Start();
loop3_no = loop3;
if (b_stop == true)
{
b_done = false;
break;
}
Application.DoEvents();
/////////////////////////////////////////status information set///////////////////////////////
double f_loop = Convert.ToDouble(loop);
double f_loopmax = Convert.ToDouble(loopmax);
string str_estimated_time = "";
if (b_time == true)
{
double d_time_left = d_time_loop / 1000 *
(loopmax * loop1_max * loop2_max * loop3_max - loop_count);
if (loop_count == 0)
{
str_estimated_time = "Time: " + "unknow, ";
}
else
{
str_estimated_time = "Time: " + Convert.ToInt32(d_time_left).ToString() + "s, ";
}
}
string str_iteration = "";
if (b_iteration == true)
{
str_iteration = "";
if (loopmax > 1)
{
str_iteration += "Loop:" + (loop + 1).ToString() + ", ";
}
if (loop1_max > 1)
{
str_iteration += "Loop1:" + (loop1_no + 1).ToString() + ", ";
}
if (loop2_max > 1)
{
str_iteration += "Loop2:" + (loop2_no + 1).ToString() + ", ";
}
if (loop3_max > 1)
{
str_iteration += "Loop3:" + (loop3_no + 1).ToString() + ", ";
}
}
if ((b_time == true) || (b_iteration == true))
{
this.toolStripStatusLabel_percent.Text = str_iteration + " " + str_estimated_time;
}
loop_no = loop;//for each module's static parameters, such as Data.reg
dic_moudle_out.Clear();
/////////////////////////////////////////////////call the module function by reflection///////////////////
for (int i = 0; i < module_list.Count; i++)
{
//change the current running module color
textBox_simulation_output.Text +="current running module: "+ module_list[i];
textBox_simulation_output.Text += Environment.NewLine;
progress_n ++;
this.toolStripProgressBar1.Value = Convert.ToInt32(progress_n / (module_list.Count*f_loopmax * loop1_max * loop2_max * loop3_max)
* this.toolStripProgressBar1.Maximum);
Application.DoEvents();
string str_percent = "";
if (b_ratio == true)
{
str_percent =Convert.ToInt32(100*progress_n / (module_list.Count*f_loopmax * loop1_max * loop2_max * loop3_max)).ToString() + "%";
this.toolStripStatusLabel_percent.Text = str_percent + " " +
str_iteration + " " + str_estimated_time;
}
if (b_module == true)
{
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == module_list[i]))
{
((MyButton)double_panel.Controls[j]).BackColor = Color.Red;
}
else
{
((MyButton)double_panel.Controls[j]).BackColor = Color.White;
}
}
}
//check the moudle is labeled pass or not
bool b_pass = false;
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == module_list[i])
&& (((MyButton)double_panel.Controls[j]).b_pass == true))
{
b_pass = true;
}
}
string str_module = "";
if (b_module == true)
{
str_module = "Moudle: " + module_list[i].ToString()+", ";
this.toolStripStatusLabel_percent.Text = str_percent + ", " +
str_iteration + " " + str_estimated_time + " " + str_module;
this.toolStripStatusLabel_percent.Invalidate();
}
if (b_stop == true)
{
b_done = false;
break;
}
Application.DoEvents();
// for input parameter of module i
Dictionary<string,>> dic_in_temp = new Dictionary<string,>>();
//for those modules with input, i.e. in_no!=0
if (list_in[i] != 0)
{
List<string> path_in = new List<string>();//save all the in path string for module i
//for each module, check the input path
foreach (KeyValuePair<string,> kvp in path)
{
if (kvp.Key.Contains(module_list[i].ToString() + "*in*no*"))
{
path_in.Add(kvp.Key.ToString());
}
}
//list the path_in in the right order according to the input no 0,1,2...
for (int m = 0; m < path_in.Count; m++)//loop in order to list all the path_in in the right order
{
for (int j = 0; j < path_in.Count - 1; j++)
{
string str_in_no_1 = path_in[j].Substring(path_in[j].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
string str_in_no_2 = path_in[j + 1].Substring(path_in[j + 1].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
if (Convert.ToInt16(str_in_no_1) > Convert.ToInt16(str_in_no_2))//exchange
{
string str_temp = path_in[j];
path_in[j] = path_in[j + 1];
path_in[j + 1] = str_temp;
}
}
}
//obtain the module out and the out no for each path_in,
//save the input parameters for module i
for (int m = 0; m < path_in.Count; m++)
{
string str_module_out = path_in[m].Substring(0, path_in[m].IndexOf("*out*no*"));
string str_out_no = path_in[m].Substring(path_in[m].IndexOf("*out*no*") + 8, 1);
Dictionary<string,>> dic_out_temp = new Dictionary<string,>>();
dic_moudle_out.TryGetValue(str_module_out, out dic_out_temp);
List<para_in_out> list_out_temp = new List<para_in_out>();
dic_out_temp.TryGetValue(str_out_no, out list_out_temp);
dic_in_temp.Add(m.ToString(), list_out_temp);
}
}
//get the module name without the no "_0"
string str = module_list[i].ToString();
string str_function = str.Substring(0, str.IndexOf("*"));
#region reflection functions
//for the modules without input
object out_temp = new object();
if (list_in[i] == 0)
{
try
{
bool b_module_non_dll = false;
for (int k = 0; k < str_module_list.Count; k++)
{
if (str_function == str_module_list[k])
{
b_module_non_dll = true;
}
}
if (b_module_non_dll == true)
{
//directly call the functions:olkd
out_temp = this.GetType().InvokeMember(str_function, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, this, new object[] { module_list[i] });
}
else
{
string str_dll = str_module_dll_path;
str_dll = str_dll + "\\" + str_function + ".dll";
AssemblyName name = new AssemblyName();
name.CodeBase = "file://" + str_dll;
Assembly asm = AppDomain.CurrentDomain.Load(name);
// Instantiate the class
string str_namespace_class = "NS_" + str_function + "." + "Class_" + str_function;
object remoteObject =
asm.CreateInstance(str_namespace_class);
Type remoteType =
asm.GetType(str_namespace_class);
// Call the method
MethodInfo method = remoteType.GetMethod(str_function + "_fun");
out_temp = method.Invoke(remoteObject, new object[] { module_list[i], module_value, loop_no, b_stop });
}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.ToString());
splitContainer1.Enabled = true;//enable the container1 during simulaiton
return;
}
}
else
{
try
{
bool b_module_non_dll = false;
for (int k = 0; k < str_module_list.Count; k++)
{
if (str_function == str_module_list[k])
{
b_module_non_dll = true;
}
}
if (b_module_non_dll == true)
{
if (b_pass == true)
out_temp = this.GetType().InvokeMember(str_function + "_pass",
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { module_list[i], dic_in_temp });
else
out_temp = this.GetType().InvokeMember(str_function,
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { module_list[i], dic_in_temp });
}
else
{
string str_dll = str_module_dll_path;
str_dll = str_dll + "\\" + str_function + ".dll";
AssemblyName name = new AssemblyName();
name.CodeBase = "file://" + "\\" + str_dll;
Assembly asm = AppDomain.CurrentDomain.Load(name);
// Instantiate the class
string str_namespace_class = "NS_" + str_function + "." + "Class_" + str_function;
object remoteObject =
asm.CreateInstance(str_namespace_class);
Type remoteType =
asm.GetType(str_namespace_class);
// Call the method
MethodInfo method = remoteType.GetMethod(str_function + "_fun");
out_temp = method.Invoke(remoteObject, new object[] { module_list[i], module_value, dic_in_temp, loop_no, b_stop });
}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.ToString());
splitContainer1.Enabled = true;//enable the container1 during simulaiton
return;
}
}
#endregion reflection functions
//save output for each module with output
Dictionary<string,>>> dic_moudle_out_temp = new Dictionary<string,>>>();
dic_moudle_out_temp = (Dictionary<string,>>>)out_temp;
if (out_temp != null) //avoid for the modules without output
{
foreach (KeyValuePair<string,>>> kvp in dic_moudle_out_temp)
{
dic_moudle_out.Add(kvp.Key, kvp.Value);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// modules loop: start ////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
#region modules loop
//check whether current module belongs to the end module of some module loops:
List<mybutton> list_loop_modules = new List<mybutton>();
int loop_modules_no = 0;
string str_current_loop_name = "";
foreach (KeyValuePair<string,>> kvp in dic_module_loop)
{
if (module_list[i] == kvp.Value[kvp.Value.Count - 1].Name)
{
dic_module_loop.TryGetValue(kvp.Key, out list_loop_modules);
dic_module_loop_no.TryGetValue(kvp.Key, out loop_modules_no);
str_current_loop_name = kvp.Key;
}
}
//if so, then loop these modules
if (list_loop_modules.Count != 0)
{
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += "current running loop: " + str_current_loop_name;
textBox_simulation_output.Text += Environment.NewLine;
for (int ii = 1; ii < loop_modules_no; ii++) //start from 1 not 0 because one loop has calculated
{
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += "current running loop no: " + ii.ToString();
textBox_simulation_output.Text += Environment.NewLine;
for (int i_loop = 0; i_loop < list_loop_modules.Count; i_loop++)
{
textBox_simulation_output.Text += "current running module : " + list_loop_modules[i_loop].Name;
textBox_simulation_output.Text += Environment.NewLine;
//change the current running module color
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == list_loop_modules[i_loop].Name))
{
((MyButton)double_panel.Controls[j]).BackColor = Color.Red;
}
else
{
((MyButton)double_panel.Controls[j]).BackColor = Color.White;
}
}
//check the moudle is labeled pass or not
bool b_pass_loop = false;
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == list_loop_modules[i_loop].Name)
&& (((MyButton)double_panel.Controls[j]).b_pass == true))
{
b_pass_loop = true;
}
}
string str_module_loop_modules = "";
if (b_module == true)
{
str_module_loop_modules = "Moudle: " + list_loop_modules[i_loop].Name.ToString();
string str_modules_loop_current = "loop:" + str_current_loop_name + " #" + (ii + 1).ToString();
this.toolStripStatusLabel_percent.Text = str_percent + " "
+ str_iteration + " " + str_estimated_time + " "
+ str_modules_loop_current + " " + str_module_loop_modules;
}
if (b_stop == true)
{
b_done = false;
break;
}
Application.DoEvents();
//for the first module in the loop, the input is assigned by the output,i.e., the last module
// for input parameter of module i
Dictionary<string,>> dic_in_temp_loop = new Dictionary<string,>>();
//for those modules with input, i.e. in_no!=0
if (list_loop_modules.Count != 0)
{
List<string> path_in = new List<string>();//save all the in path string for module i
//for each module, check the input path
foreach (KeyValuePair<string,> kvp in path)
{
if (kvp.Key.Contains(list_loop_modules[i_loop].Name.ToString() + "*in*no*"))
{
path_in.Add(kvp.Key.ToString());
}
}
//list the path_in in the right order according to the input no 0,1,2...
for (int m = 0; m < path_in.Count; m++)//loop in order to list all the path_in in the right order
{
for (int j = 0; j < path_in.Count - 1; j++)
{
string str_in_no_1 = path_in[j].Substring(path_in[j].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
string str_in_no_2 = path_in[j + 1].Substring(path_in[j + 1].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
if (Convert.ToInt16(str_in_no_1) > Convert.ToInt16(str_in_no_2))//exchange
{
string str_temp = path_in[j];
path_in[j] = path_in[j + 1];
path_in[j + 1] = str_temp;
}
}
}
//obtain the module out and the out no for each path_in,
//save the input parameters for module i
if (i_loop == 0) //the input into the first module: the output of the last module
{
string str_module_out = list_loop_modules[list_loop_modules.Count - 1].Name;
string str_out_no = "0";
Dictionary<string,>> dic_out_temp_loop = new Dictionary<string,>>();
dic_moudle_out.TryGetValue(str_module_out, out dic_out_temp_loop);
List<para_in_out> list_out_temp_loop = new List<para_in_out>();
dic_out_temp_loop.TryGetValue(str_out_no, out list_out_temp_loop);
dic_in_temp_loop.Add(str_out_no, list_out_temp_loop);
}
else //the input into the other modules: the output from the previous ones
{
for (int m = 0; m < path_in.Count; m++)
{
string str_module_out = path_in[m].Substring(0, path_in[m].IndexOf("*out*no*"));
string str_out_no = path_in[m].Substring(path_in[m].IndexOf("*out*no*") + 8, 1);
Dictionary<string,>> dic_out_temp_loop = new Dictionary<string,>>();
dic_moudle_out.TryGetValue(str_module_out, out dic_out_temp_loop);
List<para_in_out> list_out_temp_loop = new List<para_in_out>();
dic_out_temp_loop.TryGetValue(str_out_no, out list_out_temp_loop);
dic_in_temp_loop.Add(m.ToString(), list_out_temp_loop);
}
}
}
//get the module name without the no "_0"
string str_loop = list_loop_modules[i_loop].Name.ToString();
string str_function_loop = str_loop.Substring(0, str_loop.IndexOf("*"));
//for the modules without input
object out_temp_loop = new object();
//call reflection functions
try
{
bool b_module_non_dll = false;
for (int k = 0; k < str_module_list.Count; k++)
{
if (str_function == str_module_list[k])
{
b_module_non_dll = true;
}
}
if (b_module_non_dll == true)
{
if (b_pass_loop == true)
out_temp_loop = this.GetType().InvokeMember(str_function_loop + "_pass",
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { list_loop_modules[i_loop].Name, dic_in_temp_loop });
else
out_temp_loop = this.GetType().InvokeMember(str_function_loop,
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { list_loop_modules[i_loop].Name, dic_in_temp_loop });
}
else
{
string str_dll = str_module_dll_path;
str_dll = str_dll + "\\" + str_function + ".dll";
AssemblyName name = new AssemblyName();
name.CodeBase = "file://" + "\\" + str_dll;
Assembly asm = AppDomain.CurrentDomain.Load(name);
// Instantiate the class
string str_namespace_class = "NS_" + str_function_loop + "." + "Class_" + str_function_loop;
object remoteObject =
asm.CreateInstance(str_namespace_class);
Type remoteType =
asm.GetType(str_namespace_class);
// Call the method
MethodInfo method = remoteType.GetMethod(str_function_loop + "_fun");
out_temp = method.Invoke(remoteObject, new object[] { list_loop_modules[i_loop].Name,
module_value, dic_in_temp_loop, loop_no, b_stop });
}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.ToString());
splitContainer1.Enabled = true;//enable the container1 during simulaiton
return;
}
//update the output for each module in the loop
Dictionary<string,>>> dic_moudle_out_temp_loop = new Dictionary<string,>>>();
dic_moudle_out_temp_loop = (Dictionary<string,>>>)out_temp_loop;
if (out_temp_loop != null) //avoid for the modules without output
{
foreach (KeyValuePair<string,>>> kvp in dic_moudle_out_temp_loop)
{
dic_moudle_out.Remove(kvp.Key);
dic_moudle_out.Add(kvp.Key, kvp.Value);
}
}
}
}
}
#endregion modules loop
}//end: for each module
if (loop_count == 0) //only calculate one time for time estimation
{
sw.Stop();
d_time_loop = sw.ElapsedMilliseconds;
}
loop_count++;
}//end: loop 3
}//end: loop 2
}//end: loop 1
}//end: loop
}//end: for b_stop==false
if (b_done == true)
{
sw_total.Stop();
double d_time_total = sw_total.ElapsedMilliseconds / 1000;
this.toolStripStatusLabel_status.Text = "Simulation is done, total time is:"
+ (Convert.ToInt32(d_time_total)).ToString() + "s";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += this.toolStripStatusLabel_status.Text;
textBox_simulation_output.Text += Environment.NewLine;
this.toolStripButton_output_observer.Enabled = true;
this.outputWindowToolStripMenuItem.Enabled = true;
b_simulation_complete = true;
}
else
{
this.toolStripStatusLabel_status.Text = "Simulation is stopped";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += "Simulation is stopped";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.ScrollToCaret();
}
//splitContainer1.Enabled = true;//enable the container1 during simulaiton
this.toolStripProgressBar1.Visible = false;
this.toolStripStatusLabel_percent.Visible = false;
this.toolStripButton_stop.Enabled = false;//disable the stop button
this.stopSimulationToolStripMenuItem.Enabled = false;
//close all figures button
if ((dic_form.Count > 0) || (dic_form_single.Count > 0))
{
toolbutton_close_all_figure.Enabled = true;
Menu_Close_all_Figure.Enabled = true;
}
}
|
|
|
|
|
I meant post just the bit of code that does the looping.
1) What on earth is this meant to mean?
Dictionary<string,>>>
You need to escape any < or > signs in your code with < or > before you can post them.
2) Code should be posted within <pre> </pre> tags to make it more readable.
if(testValue)
{
Console.WriteLine("test");
}
Simon
|
|
|
|
|
Hi, Simon,
by the way, I saw one simulaiton tool, they provide one button to "clear the simulation", then it gives the message "Clearing memory of the simulation". that means the memory used by the simulation has been cleared. I don't know how to clear the memory used by the simulaiton? If I know how to do it, it may help me to improve my own simulation tool, especially when we have many loops.
Do you have the experiences on it?
thank you for your kind help!!
|
|
|
|
|
In .net you don't need to clear memory. Most .net objects are "managed" which means their memory is automatically reclaimed by the garbage collector, provided you don't hold references too them after they should have gone out of scope, so you don't need to worry about it.
When a class uses unmanaged memory, it will implement the IDisposable interface. In this case, you just call the Dispose() method when you are finished with it to release the objects unmanaged memory.
I've only briefly looked over your code, but I can't see any types in there that need disposing of.
Simon
|
|
|
|
|
One thing I like in Java is that their UI elements can all be interconnected around an Action object. You create an AbstractAction with an Icon and a description string, and then you can associate it with any controls, which will all have the same action when activated (click a button, select a menu item, click a toolbar button, etc...), have the same description, and are all enabled and disabled together, all that through the Action object. I haven't tested to see if changing the icon and the description also cascades.
Is there a similar functionality in C# 2.0? Did someone write some class with this functionality? I realize that it's not very hard to code by oneself, but if I can use a proven implementation, or work with someone else, all the better.
EDIT : precised that I want .NET 2.0
This has been added to the framework in C# 3.0, but I must use .NET 2.0
"Computer Science is no more about computers than astronomy is about telescopes." - Edsger Dijkstra
modified on Tuesday, October 14, 2008 12:01 PM
|
|
|
|
|
|
Oh, cool.
Is there anything in .NET 2.0, though? (I forgot to mention that, sorry)
"Computer Science is no more about computers than astronomy is about telescopes." - Edsger Dijkstra
|
|
|
|
|
Can't think of anything. (That doesn't mean that there isn't. the framework is too big for me to remember everything). Last time I wrote an in .net 2.0 thought I wrote my own command handling framework, which I used on several projects.
Simon
|
|
|
|
|
Hello every one !
I have a wsdl and proxy file of webservice provided by Innovative gateway
but problem is i am not able to discover the method of that web services due to this i am not connect my web site to innovative gateway.
thanks
sam
Web Developer
|
|
|
|
|
shames(Sam) wrote: but problem is i am not able to discover the method of that web services
Maybe this[^] will help you.shames(Sam) wrote: i am not connect my web site to innovative gateway.
I don't know what that means.
led mike
|
|
|
|
|
To connect and use the Web Service you can use this URL
https://webservices.innovativegateway.com/IGSPaymentService/IGSPaymentService.asmx
and i have WSDL and proxy class of
web service which is undiscoverable for security reasons.
Web Developer
|
|
|
|
|
Hello everyone!!!
Me and this problem again!!! =D
This is my code:
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\Painel de Controle ETECH\Projetos ETECH\{0}\80010005.dwg";
shellExecute.Execute();
}
It works BUT open only the file written in the shellExecute.Path statement
I need to find a way to execute a selected file on the list view...
Well I´d many ideas and none worked.. I was thinking to put the selected file on a string and then to put this string on the end of the path statement but I didn´t figure out how to do it and mainly how to put the file name on a string when I select it on the list view control!
Could anyone help me?? I´m very desperate!!!!
best wishes for all!!!
|
|
|
|
|
Gianpaolo Barci wrote: I was thinking to put the selected file on a string and then to put this string on the end of the path statement
if you mean shellExecute.Path = someString; yes that would be the thing to do.
Gianpaolo Barci wrote: but I didn´t figure out how to do it
why not? That is a programming 101 concept. What is your programming background?
led mike
|
|
|
|
|
shellExecute.Path = someString; and someString represents the path to the file I selected on the listView control. Yes, It means that I´m in the right way now. The problem is right here... select the file in the ListView and put it´s path and it´s name on a string...
I´m a totally dummy with event oriented programming. My knowledge is structured C, Data Structures on C.. I can do an entire B-Tree using C but I can´t implement a simple event.. oh shame on me... =(
|
|
|
|
|
How are you populating your listview with the files? Where is the file information coming from?
Each ListViewItem has a Tag property that holds an object. Save your full path to the file in there. When you need it, just cast that ListViewItem's Tag to a string and you've got the file's path.
Alternatively, create a custom ListViewItem that has a Path property, then you can cast the entire item to your class and access the Path property.
public class ListViewItemWithPath : ListViewItem
{
public ListViewItemWithPath(string fileName, string path)
{
Text = fileName;
m_Path = path;
}
private string m_Path;
public string Path
{
get { return m_Path; }
set { m_Path = value; }
}
}
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)
|
|
|
|
|
Dave
I got your point!!! Working on it right now!!!
Thanks
|
|
|
|
|
I did this!
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
string filePath = lvFiles.SelectedItems.ToString();
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\\Painel de Controle ETECH\\Projetos ETECH" + filePath;
shellExecute.Execute();
}
Am I close??
|
|
|
|
|
Did you sort 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)
|
|
|
|
|
hi all,
we developed windows application using vs 2005,in this application we used crystal reports for reports,we have to deploy these Crystal reports along with setup file,how can we do this ,please help us.
|
|
|
|
|
It is pretty easy.
Right click your Deployment project -> Select View -> File System:
File System View will be displayed.
You can either right-click to select a Special folder or use for example Application folder.
Enter Application folder for this example and right click again. You will see the required menus to add a file, Project output, etc...
Hope this helps...
Always keep the Murphy Rules in mind!
|
|
|
|
|
Crystal Reports has the required merge modules on their website. Integrate them into your deployment project and it will go fine. Another option is to download the MSI for the particular version from their site and manually run them on the deployment server.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
Most of this sig is for Google, not ego.
|
|
|
|
|
As a parent, sometimes you have to watch your kids. You have 2 ways to do this; either limit their actions entirely or snoop in on them. I have the need to do the latter. As somewhat of a beginner / intermediate developer, I want to create some sort of application to monitor, log and report my children's activities on their respective PCs.
After reading the board for a good week now (both VB.NET and C#) I know that this type of post isn't welcomed at all, and I will probably get scolded for branching on the topic due to it's controversy with flirting on the distinct line of privacy invasion but here it goes;
I want to create a "key logger" of sorts, to monitor what people do, who they chat with and what they are chatting about. After reading a bunch, trapping the print screen seems like a nice start, but I am afraid that if done frequently, will I be eating to much resources, slowing down the machine, eating to much network traffic and allocating to much disk space where my child will know what is going on? I am not concerned about AV because my child, albeit knowledgeable of computers to a degree, doesn't have an AV.
So I guess, where would I start looking to trap all keys pressed in whichever application, or at least solely MSN chat windows and internet explorer. I am not after login and passwords here, just trying to make sure my family stays 'kosher'.
So before you distrust the post, understand I wouldn't resort to this unless I had to.
Thanks in advance for the reading.
modified on Tuesday, October 14, 2008 9:50 AM
|
|
|
|
|