|
Hello,
andredani wrote: My question is how do i stop the timer with a button2 click???
You found the "Start()" method, but not the "Stop()" method.
Anyway, you could also set the Boolean "Enabled" property "true" or "false"!
andredani wrote: And do u know any good sleep or wait function???
"Thread.Sleep(timeinms)" will freeze the thread (Also GUI if it's the main thread).
Hope it helps!
All the best,
Martin
|
|
|
|
|
You can use Enabled property for System.Timer or for System.Windows.Form.Timer
andredani wrote: And do u know any good sleep or wait function???
Is it very difficult to guess that 'sleep' function is called Sleep()?
|
|
|
|
|
Giorgi Dalakishvili wrote: Is it very difficult to guess that 'sleep' function is called Sleep()?
Well, it might very well have been called "delay".
|
|
|
|
|
hi
I want to get the value of specified row and column from dataGridview e.g. value of row2 column3,is there any method of datagridview that can return me the value of cell(col#,row#) or tell me how I can get value of 1st column if user select whole row.
Regards
Shanzay
|
|
|
|
|
myDataGridView[columnnumber,rownumber].Value returns the value at the intersection of columnnumber column and rownumber row
|
|
|
|
|
You can get first row's first column value using this code
GridView1.Rows[0].Cells[1].Text
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
Hey Guys,
i search a tool to configurate easily Log4Net.
Can someone help me?
Thanks
Patrick
|
|
|
|
|
Any good way/library/dll/activex/plug-in/add-on to output data from C# through ADO to ms word document and then format it as tables and text??
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
You could do this with Word itself via VSTO (Visual Studio Tools for Office) or you could use something like Aspose.Words[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
hmmm.. "VSTO!"
Thanks Pete.
Smile: A curve that can set a lot of things straight!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hello,
The code bellow shows a C# application loading an unmanaged C++ DLL. Note that the DLL uses a function pointer to call back one of the C# functions and pass arguments to it.
C# code
using System;
using System.Runtime.InteropServices;
namespace CsharpManaged
{
class Program
{
public delegate void CallbackDelegate([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] String[] ar, int len);
[DllImport("CppDLLUnmanaged.dll", CallingConvention = CallingConvention.StdCall)]
private static extern void SetCallBackPointer(CallbackDelegate DelegatePassedToDLL);
[DllImport("CppDLLUnmanaged.dll", CallingConvention = CallingConvention.StdCall)]
private static extern void InvokeCallBack();
static void Main(string[] args)
{
SetCallBackPointer(new CallbackDelegate(CallbackFunction));
InvokeCallBack();
Console.ReadLine();
}
private static void CallbackFunction(String[] ar, int len)
{
Console.WriteLine("I'm an array of " + ar.Length + " positions!");
foreach(String element in ar)
{
Console.WriteLine(element);
}
}
}
}
C++ code
typedef void __stdcall CALL_BACK_FUNCTION(char* ar[], int len);
CALL_BACK_FUNCTION *pFunction;
__declspec(dllexport) void __stdcall SetCallBackPointer(CALL_BACK_FUNCTION* FnAddress)
{
pFunction = FnAddress;
}
__declspec(dllexport) void __stdcall InvokeCallBack()
{
int len = 5;
char** myArray = new char*[len];
myArray[0] = "A";
myArray[1] = "AB";
myArray[2] = "ABC";
myArray[3] = "ABCD";
myArray[4] = "ABCDE";
pFunction(myArray,len);
delete [] myArray;
}
In the example I pass a string array from the DLL to the application. The contents arrive correctly, but I can't modify them.
What I need to do is add an extra argument in the call back function. Say, instead of
typedef void __stdcall CALL_BACK_FUNCTION(char* ar[], int len); I want it to be
typedef void __stdcall CALL_BACK_FUNCTION(char* ar[], int len, char* result); This extra argument is actually a return variable: I need the C# application to write something in it, and then the DLL should be able to use the data that was written.
I tried allocating the memory for this char* result buffer in the DLL, and then receiving it in the C# as a marshalled String . However, I'm not allowed to write in that String. Or rather I am, but the modifications don't take effect once I return to the DLL.
I'd appreciate any suggestions anyone might have in solving this problem.
Regards,
Leonardo
|
|
|
|
|
Just bumping the thread up a bit, in case someone who knows the solution has missed it. Please don't hesitate if you have any suggestions on how to get this working.
|
|
|
|
|
Hi,
I found a solution to the problem. I'm not sure if it's the best one, since I'm forced to use unsafe code, but it works. The code example I give below is a variation of the one in my previous post. To show that the mechanism works, I simply write the input buffer into the output buffer.
Thanks anyway to anyone who might have spent time looking for a solution.
C#
using System;
using System.Runtime.InteropServices;
using System.Globalization;
namespace CsharpManaged
{
class Program
{
public delegate void CallbackDelegate(
IntPtr INBuffer, UInt32 INBufferLength,
IntPtr OUTBuffer, UInt32 OUTBufferLength);
[DllImport("CppDLLUnmanaged.dll", CallingConvention = CallingConvention.StdCall)]
private static extern void SetCallBackPointer(CallbackDelegate DelegatePassedToDLL);
[DllImport("CppDLLUnmanaged.dll", CallingConvention = CallingConvention.StdCall)]
private static extern void InvokeCallBack();
static void Main(string[] args)
{
SetCallBackPointer(new CallbackDelegate(CallbackFunction));
InvokeCallBack();
Console.ReadLine();
}
private static void CallbackFunction(
IntPtr INBuffer, UInt32 INBufferLength,
IntPtr OUTBuffer, UInt32 OUTBufferLength)
{
Console.WriteLine("C#:");
unsafe
{
Byte* INptr = (Byte*)INBuffer.ToPointer();
Byte* OUTptr = (Byte*)OUTBuffer.ToPointer();
UInt32 length =
(INBufferLength < OUTBufferLength) ? INBufferLength : OUTBufferLength;
for (UInt32 i = 0; i < length; ++i)
{
Console.WriteLine(Convert.ToString(*INptr));
*OUTptr = *INptr;
++INptr;
++OUTptr;
}
}
Console.WriteLine();
}
}
}
C++ DLL
#include <iostream>
using namespace std;
typedef void __stdcall CALL_BACK_FUNCTION(char* INBuffer, unsigned long INBufferLength,
char* OUTBuffer, unsigned long OUTBufferLength);
CALL_BACK_FUNCTION *pFunction;
__declspec(dllexport) void __stdcall SetCallBackPointer(CALL_BACK_FUNCTION* FnAddress)
{
pFunction = FnAddress;
}
__declspec(dllexport) void __stdcall InvokeCallBack()
{
char* INBuffer, * OUTBuffer;
unsigned long INBufferLength, OUTBufferLength;
INBufferLength = 10;
OUTBufferLength = 15;
INBuffer = new char[INBufferLength];
OUTBuffer = new char[OUTBufferLength];
for(int i = 0; i < INBufferLength; ++i)
{
INBuffer[i] = i;
}
pFunction(INBuffer,INBufferLength,OUTBuffer,OUTBufferLength);
cout << "C++" << endl;
for(unsigned long i = 0; i < OUTBufferLength; ++i)
{
char digit;
itoa(OUTBuffer[i],&digit,10);
cout << digit << endl;
}
delete [] INBuffer;
delete [] OUTBuffer;
}
|
|
|
|
|
I want to search a file from server and want to copy it to the local disk.
how it is done? This is working if the file is in my hard disk itself.But not when it comes to server. If i map the server i can search.like y:\\serverfolde\\folder am tring to make an exe. different people will map to different drive. so i cant give like that.should give like @\\server\\serverfolde\\folder\\ but it is not working.
My code is
<br />
searchfolder="y:\\Template\\else";<br />
destination ="D:\\Princy\\My Documents\\project\\";<br />
string source=searchfolder+"\\"+"mod501_"+filetosearch+".3d";<br />
string target=destination+"mod501-"+filetosearch+".3d";<br />
string[] files = Directory.GetFiles(searchfolder, "mod501_"+filetosearch+".3d");<br />
if(files.Length==1)<br />
{<br />
foreach (string dir in files) <br />
{<br />
lblcnt.Text="Selected File: "+ dir;<br />
string[] search = Directory.GetFiles(destination,"mod501-"+filetosearch+".3d");<br />
if(search.Length>0)<br />
{<br />
lblcnt.Visible=true;<br />
lblcnt.Text="File already exist";<br />
}<br />
else<br />
{<br />
File.Copy(source,target);<br />
lblcnt.Visible=true;<br />
lblcnt.Text="File copied";<br />
}<br />
}<br />
what to give insted of
searchfolder="y:\\Template\\else";
If am using
searchfolder="@books\\template\\Template\\else";
am geting error:
System.IO.DirectoryNotFoundException:Could not find a part of the "@books\template\Template\els".
Otherwise its working perfectly.
|
|
|
|
|
Well for a start, you can't start a directory name with @. I assume you are wanting it to be something like @"\\server\directory\subdirectory". If you use the @, you put it before the quote and you double slash the server name.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
when i deployed my application,after some time am getting this error in server.(like after one day then am getting this error in my server and it is displaying "Service UnAvailable")
Error:
Application pool 'DefaultAppPool' is being automatically disabled due to a series of failures in the process(es) serving that applicat)ion pool.
any help appreciated.
Thanks
|
|
|
|
|
According to Microsoft, this may be caused by this[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
i checked all the permissions for network it got full permissions.
A process serving application pool 'DefaultAppPool' exceeded time limits during shut down. The process id was '3796'.
this is wht the exact error msg wht am getting.
any help?
Thanks
|
|
|
|
|
hi all.
currently now i have a problem of saving the different data in the textbox into different files.
for example, when someone enters "hello" in textbox1 as "message.txt", and clicks send button, the streamwriter will save the file into a notepad as "message.txt" and the content will be "hello".
but is it possible to store that notepad permanently such that if the user clicks the send button another time with a different content like "goodbye", the streamwriter will save the file into a different notepad like "message2.txt" and the content will be "goodbye" ?
Hence, I will have 2 notepads in my debug folder, message.txt and message2.txt . is this possible?
help thanks!
|
|
|
|
|
For a start, you don't save the files to notepad. You save them as text files which can be opened with notepad.
Secondly, you need to write the file out using a FileStream.
FileStream fs = new FileStream("message.txt", FileMode.Create, FileAccess.Write, FileShare.None, 8192, false);
fs.Write(textValue, 0, textValue.Length);
fs.Close();
fs = null;
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for replying. I've tried using FileStream and it works.
But how do i write the logic such that the name of the file changes whenever the FileStream is used?
|
|
|
|
|
troubled one wrote: for example, when someone enters "hello" in textbox1 as "message.txt", and clicks send button, the streamwriter will save the file into a notepad as "message.txt"
StreamWriter is not saving into notepad. It's saved as .txt file, and it's extension is mapped with notepad.exe on windows.
troubled one wrote: but is it possible to store that notepad permanently such that if the user clicks the send button another time with a different content like "goodbye", the streamwriter will save the file into a different notepad like "message2.txt" and the content will be "goodbye" ?
Use a filestream instead of StreamWriter. StreamWriter won't be able to create a file. But filestream can create file and write data to it. You need to keep a logic to avoid repeating the file name, if you are creating many files.
|
|
|
|
|
N a v a n e e t h wrote: StreamWriter won't be able to create a file.
Are you sure? StreamWriter creates a new file if it doesn't exist.
|
|
|
|
|
Giorgi Dalakishvili wrote: StreamWriter creates a new file if it doesn't exist.
YES.. I missed that point.
|
|
|
|
|
If you don't write large amounts of text and performance is not critical, you can also use the File class, which makes it trivially easy:
File.WriteAllText("message.txt", "Hello!");
If you'd like to append instead of overwriting, use File.AppendAllText .
|
|
|
|