Answer Questions
CSH100885 Unable to delete folder - being used by another process
When I try to delete a directory I get an IOException because it is being used by another process. The only process that is using it is the one trying to delete it. To prove this I created a folder and added a txt file to it. I started the app, used an OpenFileDialog object to get the string of the selected file. I then try to delete the file but get the exception - I also get the error if I try to delete the file through Windows Explorer. When I close the app I can delete the directory in windows explorer. I don't understand why this is happening as I have disposed of the object. Is the OS holding onto something that I need to clean up Here is a simple example of the problem. try { OpenFileDialog openFileDialog1 = new ...Show All
Sara_H Problem debugging generic classes
Anyone knows how to solve this When I try to debug my generic class, I doesn't allow me to watch the value. Here is my sample code :- //* In a Windows Form private void button2_Click( object sender, EventArgs e) { DictionaryWrapper < int > tmpDic = new DictionaryWrapper < int >(); tmpDic.AddEntry(6); tmpDic.AddEntry(16); tmpDic.AddEntry(3); tmpDic.AddEntry(33); } //* My own Class public class DictionaryWrapper <T> { Dictionary <T, int > myDic; public DictionaryWrapper() { myDic = new Dictionary <T, int >(); } public void AddEntry(T inKey) { myDic.ContainsKey(inKey); // <====== I set a breakpoint here ********** ...Show All
Batikit Convert array to nullable array
Hi, The following code does'nt compil : int[] tab = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int [] nulltab = (int [])tab; Cannot convert from 'int[]' to 'int [] How I can cast my array Thanx I tried to create the following function but that doesn't works to static T[] ConvertArray<T, V>(V[] array) { T[] nullableArray = new T[array.Length]; for ( int i = 0; i < array.Length; i++) nullableArray[ i] = (T)array[ i]; return nullableArray; } =>Cannot convert 'V' to 'T' Can you help me int and int are assignment compatible but not blittable. Workarounds are to make "tab" of t ...Show All
Jonathan Cran Adding text to a listbox
I am trying to add text to a listbox by using a string type variable. During debug I noticed that the variable had the text I wished to add to the listbox, but the listBox1.Items.Add(s_Text); didnt' do anything. Is there a different way your supposed to do this I wasn't talking about a Textbox control, but a string variable. The variable is recieving a value from an object successfully, but will not add it to a listbox for whatever reason. Did you try to add a string value like "hello" and see what happends. Maybe you are adding values in wrong listbox. Play with your code when you have such unpredictable situation. Maybe your listbox don't shows items, or lis ...Show All
lbugnion Online Visual Studio.Net IDE
How Popular will eb something like this.. ONLINE VS.NET IDE We dont have to install the VS.NET but just to type a url and then code whatever we want get the output. What do u feel Depends on your concent of "online". You can use Visual Studio "online" via the virtual labs: http://msdn.microsoft.com/virtuallabs/vstudio2005/default.aspx I don't see the point of something like that for full-time Visual Studio development though. Because Visual Studio is so much more than a code editor I doubt that we will see an online version of Visual Studio in the near future. There is however a better way and that is to bring the online experience to the IDE, this is where Project " ...Show All
Garry W How to get the full path of a file?
Hi, all In my application, I need to read data from a text file and compare it with desired ones to see whether the data is OK. There is a button named "Import Text File" on the form, and in the Click Event, I write the following codes: private void Openbtn_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "C:\\"; openFileDialog.Filter = "Text files(*.txt)|*.txt|All files(*.*)|*.*"; openFileDialog.FilterIndex = 0; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { try { } catch(Exception ex) { MessageBox.Show("Error: can not read file from disk.Original error: " + e ...Show All
tatman blue using the event keyword vs. not doing so
I'm trying to understand the differnce between declaring a variable/object with/without event keyword. Till now I could not determin any difference. Does anybody know any difference besides the word "event" The following displays exactly the same behaviour for notifyHandler and ne: delegate void NotifyEvent ( string s); event NotifyEvent notifyHandler; NotifyEvent ne; private void doNotify( string text) { MessageBox .Show( "kjashlkajsd" , text); } private void button1_Click( object sender, EventArgs e) { if (notifyHandler != null ) { Delegate [] dl = notifyHandler.GetInvocationList(); foreach ( NotifyEvent d in dl) notifyHandler -= d; } no ...Show All
Rajwebdev DllImport array of struct fails
C++: // declare int _stdcall ReceiveAllMessage(SM_PARAM *sm_param); // usage SM_PARAM *sm_param_temp = new SM_PARAM[30]; int temp = ReceiveAllMessage(sm_param_temp); int i=0; while(i<temp) { Method1(sm_param_temp->TP_SCTS); Method2(sm_param_temp->TP_UD); sm_param_temp++; i++; } I get error System.Runtime.InteropServices.MarshalDirectiveException: Can not use SizeParamIndex for byref array parameters. when my code running: C#: // declare private struct SM_PARAM { [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)] public string SCA; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)] public string TPA; public char TP_PID; public char TP_DCS; [MarshalAs(UnmanagedType.ByValTStr, SizeConst=16)] public string TP ...Show All
hotsauce still not getting communication between classes
alright, let me try and explain this: I have a main class that creates new instances of two other classes (class 1, class 2) "class 1" needs to do a lot of work with info from "class 2", but unfortunately can't access it. I could pass it all in as parameters from the main class (which obviously can acess both "class 1" and "class 2" as it created them), but this would be insanely difficult ( due to how much stuff it works with). I thought that i could simply create a public version of class 2 in the code for the main class by saying public classname Class2 ( get { return class2; } set { class2 = value; } ) I then tried to access "class 2" in "class 1"'s code by saying main ...Show All
MMEZIL sendkeys.send doesn't work from backgroundworker
hello, I have a backgroundworker component . In the event handler for it I use sendkeys.send but it doesn't work. However when I try sendkeys.sendwait it works. Why ...Show All
Vitalijus Looking for info on filehandling
I am looking for some good info on file IO with visual C#, i'm a log-file maniac and among other things i want to dump all the textboxes into a plain textfile. I'm also looking for info on how to interact with a printer. Any info will be helpful, thanks, Thanks for the reply, i'm still haivng some trouble though. In my test application i want to simply save the contents of a rich textbox to a txt file. this is the code: System.IO.StreamWriter myText = new System.IO.StreamWriter(@"c:\test2.txt"); myText.Write(mainText.Text); myText.Close(); The problem is that it just saves everything in a single line, im trying to achive a notepad like thing but it just dosent work. Do i really have to loop through the string and manually ...Show All
Brainsponge Importing C++ Express project to C# express?
Hi, I am new here and I am wondering if it is possible to import C++ express project into C# express ... Best Regards, Johney Please define "import." Do you mean have a C++ project sitting along side a C# project as one can do in the higher versions of Visual Studio No... that is one of the limitations of the Express Editions... single language per IDE, even if multiple ones are installed. Do you mean port the C++ code to C# If so... be prepared for an awful big headache unless your code is managed C++ code from the start. Hi Anson, Actually, I am just trying to port my codes over to C++.. but wondering if there is an easy way to do it... Best Regards, Johney ...Show All
Alex Farber Value conversions between datatypes
I'm migrating a program from C++ unmanaged to C# managed. This software reads from binary encoded files a whole bunch of information. The files are set up to store values in large buffers in the file in a very generic way so any particular DWORD sized segment inside one of these buffers can contain a value of a variety of different simple datatypes. For example, an entry could contain a byte a char a char[4] a uint16 a float etc... Now in the C++ software this was accomplished using a typedef struct with a union in it. The union had a member for all the various datatypes that the entry (DWORD size) would contain. Something like so: typedef struct Generic { union { DWORD dwdata; int intdata; &n ...Show All
vijil Difference between isEqualTo() and "=="
Hi all, I have doubt about difference between == and isEqualTo method in C#. Use .Equal for reference types and == for value types. It exists also .ReferenceEquals method which tell us if the 2 object instances are the same. Well, they should be totally same. With 3rd party classes, this cannot be totally assured, but convensions recommend that class implementers first implement Equals method, and use that method when implementing == operator. In .NET classes, they are all the same. Thank you friends for explaining this to me. basically brother "isEqualTo()" compare equality at memory locations level (Pointers) better for those data types which stored on heap l ...Show All
Puil ToolStrip problem
Hi I need help with switch statement. I am getting an error "a value of an integral type is expected". and this is the code: private void toolStrip1_ItemClicked( object sender, ToolStripItemClickedEventArgs e) { switch (toolStrip1) { case toolStripNew: newToolStripMenuItem_Click(sender, e ); break ; case toolStripOpen: openToolStripMenuItem_Click(sender, e ); break ; } } Your problem is the folloiwng if you want to use Switch you can only use only Integral types The following table shows the list integral types Type sbyte byte char short ushort ...Show All
