Answer Questions
MJC2006 Copy file to folder
string cpath = listBox2.SelectedIndex.ToString(); string cpath2 = cpath + "temp"; if (cpath.Substring(cpath.Length-3,3).ToLower() == "xml") { File.Copy(cpath, cpath2); } I have a listbox of folders and when i click a folder the files appear in my listbox2...i want to select one the files click by button and that file is copied to my c:\\temp folder.....I am getting the exception that my start index must be less than zero....any help...thanks! I feel you might be getting an error that the start index can not be less than zero Check the value of SelectedIndex. It might be -1 because nothing in the listbox is selected. if ( Path.GetExtension (cpath).Equals(". ...Show All
Ilya_X1 Normal Distribution
Is there a built-in math function to calculate normal distributions in VB or C# - like that in excel - NORMSDIST() This function is not available in any of the framework classes as far as I know. I would think there are implementations to be found on the internet... Thanks Rick van den Bosch for the fast response. If I could only get that kind of speed for my other posts. I found the math equation with some other language's sample code and converted it to C# below. (simular to Excel's NormsDist()) public double CND( double X) { double L = 0.0; double K = 0.0; double dCND = 0.0; const double a1 = 0.31938153; const dou ...Show All
Daniel McGloin Process class used from Windows Service fails
I'm having trouble with the Process class. I have a Windows Service running as SYSTEM and I want it to spawn processes on behalf of users. I get the user's password there securely and create a SecureString. I get a Win32Exception "Access Denied" on Process.Start. If I run the service under the same account as the user I want to start for, I still get the exception except it says "The handle is invalid". I've checked and checked the SecureString and I've made it read-only so I don't think that's it. I actually had gotten it to work some time ago if I impersonate the client but this isn't really practical since the job can be queued up waiting for some time. I've signed all the assemblies involved and I've given the ...Show All
KeithGWilliams Quite poor error message with COM interop compilation in VS2005
At least C# express and Microsoft Visual Studio 2005 Version 8.0.50727.42 (RTM.050727-4200) Microsoft .NET Framework Version 2.0.50727 When creating a dead simple com interoperable DLL project (btw I suck at COM), if you do this stoopid thing, which I did: 1. mark assembly as COM interoperable 2. mark output as COM interoperable 3. Assign static GUID to your assembly 4. put the same guid as a marker for you class (this, was the error) 5. Create an explicit interface [InterfaceType(ComInterfaceType.InterfaceIsDual)] public interface IComTestexposer1 { //code here } 6. make the class implement the interface. 7. try to compile and get error The assembly "C:\\VSProjects\Comtest.dll\Comtest.dll\bin\Debug\Comtest.dll" could not be co ...Show All
Andreas Kranister How do I stop running a function?
Hello, I need to know how I can stop running a function in the middle of running it. I cannot give any real coding examples but, I can get a structural example and show what I mean. private void TestFunc(string a, string b) { while(a != b) { try { // Code that should run like normal. } catch(Exception ex) { // If the code gets here I should stop the entire function right away! (TestFunc) } } } If the code gets to the catch I have to stop executing the function right away and run another function (which is handled elsewhere). This is a very newbie question but, I've not had to do this yet. Thanks for any help. Quilnux If I can just re ...Show All
apsync How to catch Exception that throw by timer
I have a WinForm application and a timer inside. The timer will throw an Exception while event Elapsed. How can I catch this Exception in WinForm other point I like to add is why are you throwing an exception in the timer event It's not recommended. If you need to check inputs, be sure to use a Char.IsNumber/whatever as this will return true/false I just want to throw exception and catch it in other method. I'm doing it in another way. Use delegate to replace with throw. Before, I want to use something that likes GlobalError to catch exception, and restart the program when any exception raise. Following CAN'T work: try { Application.Run(new Form1()); } catch { System.Diagnostics.Debug.WriteLin ...Show All
mcdonaldn Conversion Wizard error - Web project component not installed
Web project component not installed. Unable to convert project: http://localhost/somedir/myproj.csproj I am running VS2005 and have installed the 2 required downloads to enable web application projects. I can confirm this by seeing in Help --> About Visual Studio, "Microsoft Web Application Projects 2005 Version 8.0.60504.00" is listed. My solution has 7 projects in it and the other 6 report "converted successfully", only the web project fails. For some reason my Add/Remove programs shows VS 2005 Premier Partner Edition, in addition to Standard Edition. I also see the 2005 Web Application Projects installed there. So why is my conversion failing http://msdn2.microsoft.c ...Show All
Jesper Kleis Jensen getHidGUId API call error
I try to call the function HidD_GetHidGuid from hid.dll, but it gives me an error, can someone explain y thanks my piece of code is : public partial class Form1 : Form { [ DllImport ( "hid.dll" )] private static extern void HidD_GetHidGuid( Guid GUID); public Form1() { InitializeComponent(); } private void button1_Click( object sender, EventArgs e) { Guid HidGuid = new Guid (); HidD_GetHidGuid(HidGuid); textBox1.Text = HidGuid.ToString(); } } the error (when i click the button) is : Attempted to read or write protected memory. This is often an indication that other memory is corrupt. thank u Thank you The Guid ...Show All
joeydj Application design question - data downloads from internet
Hi everyone, I have been wracking my brain over this and simply can't seem to think of the problem any other way. So I thought I'd look to see how other people would approach the problem. Basically, what I'm facing is this. My application is intended to provide a GUI-based way to view data that is displayed on websites. This involves screen-scraping - downloading web pages and then parsing them for the data I want (no way around that, unfortunately). I have an object designed to store the parsed data, which is stored in flat files. The object returns the data when requested, or if the data hasn't been downloaded yet, it is supposed to download the data from the required web pages - this will happen when an MDI form is opened that requests ...Show All
Alan Browne tab control selected index event
i have encountered a starnge behavior with the tab control in visual studios 2005 or in code compiled under VS 2003 but run under framework 2.0: if i try to change the control's selected index in " regular" code (for instance, in the constructor) the selected index change event will not be raised and the callback function will not be called. changing the control's selected index through the GUI or even from another callback function, like on_Button_Pressed or on_Timer_Tick will raise the event. does anyone have any idea what is the reason for this strange conduct important to mention that this problem does not reconstruct in other controls under the framework 2.0, and does not apply for framework 1.1 build the following cod ...Show All
stak32 Read a file in a window !!!
Hi Is it possible to view and handel an Autocad or PDF file using C# Thanks Yes, there are various libraries for doing this. Here are a few: http://csharp-source.net/open-source/pdf-libraries http://sourceforge.net/projects/itextsharp/ - Charlie Thanks Here is another. http://www.woutware.com/ ...Show All
SalmanSheikh My DIE Behaves bad on my laptop.
Hi On my laptop I have the problem that I can’t seem to open more than 3 files at the same time. Actually its not a defined number of tabs, let me explain. I open a solution and select a .cs file, it opens, now I select a 2nd one; this can: cause the first tab to close or just opens a tab with a 2ns file. Now every time I open one more file the left most tab closes and is replaced by the new file in the new tab. Sometimes I get to open 5 tabs, some times only one. I have a dual core with a gig of ram, same as my workstation. Suggestions anyone Go to Tools/Options, under Environment node you have Document. On the Documents page the first check box is &quo ...Show All
Dhiraj12345 .NET or CF.NET
Hi... I am really very new in .NET programming. I have to develop an Application for Win XP-Embedded. Which Framwork should I use Normal .NET or Compact Framework Thanks.. I think that .NET for Embedded XP is called .NET Micro Framework . ...Show All
J. Nail Edit column
Hi everybody, i want to display xml file into grid view but how do i change the column display but putting the tel to be the first column instead of supplier to be in the first column. Anyone can help string [] p = getXMLFile(); DataSet mainDataSet = new DataSet (); DataSet ds = new DataSet (); for ( int i = 0; i < p.Length; i++) { ds.ReadXml(p ); mainDataSet.Merge(ds); } gvQuotation.DataSource = ds; gvQuotation.DataBind(); < xml version="1.0" encoding="utf-8" > <Quotation> <Product ID="pid852"> <Supplier>Joelle Inc </Supplier> <Fax>85203698</Fax> <Tel>89562333</Tel> &l ...Show All
RAB36 What is the point of a virtual method?
I have been working under the assumption that: 1) If I have a method that I don't want to define in the base class, I can use the abstract keyword in the base class, and all derived classes will require me to create their own copy of the method. 2) If I want to create a 'default' method for the base and most of the derived classes, I can define it as virtual in the base and then override it if needed in specific derived classes, using the override keyword. But I just noticed that I can override non-private methods (and even fields) using the new keyword. So, why would I bother with the virtual keyword, if I can just override any method using new It seems that I can use new with or without the ...Show All
