|
byte[] byteArray = new byte[12] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };<br />
string byteArrayInString = Encoding.ASCII.GetString(byteArray);<br />
char[] byteArrayInCharArray = byteArrayInString.ToCharArray();
|
|
|
|
|
Parshant Verma wrote: Iwant to convert it char
You can use following:
Array.Copy(<bytearray>,<chararray>, <no. of="" characters="" to="" copy="" from="" byte="" char="" array="">);
Regards,
Wasif Ehsan.
|
|
|
|
|
See here[^] maybe it is some helpful to you
|
|
|
|
|
what is view state in .net technology and importance of view state?
|
|
|
|
|
|
Hi,
I have a C#.net application. I have two C++ dlls with same name (but different version numbers that i see in the dll). When I use Dll Import to invoke methods on each dll separately in two different applications, all the methods in both the c++ dlls work fine.
But if i tend to use dll import and invoke the functions in the two dlls, the first dll's methods are executing fine but when the second dll's methods are invoked, there is an error stating "cannot load the second dll. method not found".
I wonder if it is something to do with loading two same named dlls in the same memory of an exe...
Please help in identifying the cause and kindly clarify my doubt.
Many Thanks.
|
|
|
|
|
Please don't cross post.
---
b { font-weight: normal; }
|
|
|
|
|
I am dealing with something related to .NET and C# and wonder about your comment. Hope you are clear in understanding my problem.
|
|
|
|
|
I am trying to use the Calculator in my win forms and i so i am trying to capture the Edit class from the Calculator ( The edit class is the textbox on the Calculator).
I am not able to figure this out..
I need some direction...
here is what i have so far...
----------------------------------------------
[DllImport("User32.dll")]
public static extern Int32 EnumChildWindows(IntPtr hWndParent, Delegate lpEnumFunc, int lParam);
-----------------------------------------------
public partial class Form1 : Form
{
delegate int CallBack(IntPtr hwnd, int iPram);
public Form1()
{
InitializeComponent();
}
private Process _Process = null;
private void button1_Click(object sender, EventArgs e)
{
this._Process = Process.Start("calc");
CallBack callback = new CallBack(EnumChildGetValue);
Win32Functions.EnumChildWindows(this._Process.Handle, callback, 0);
}
public int EnumChildGetValue(IntPtr hWnd, int lParam)
{
int txtValue;
string editText = "";
StringBuilder className = new StringBuilder(256);
txtValue = Win32Functions.GetClassName(hWnd, className, 256);
editText = className.ToString().Trim();
return 1;
}
}
in the callback i am tring to locate the different class howver this is not working correctly..
erik
|
|
|
|
|
does anyone have a tab control derived user control class which display like office 2003 shared workspace's style?
Very thanks!
jacklin
|
|
|
|
|
Hi all,
After installing google notebook, a button will be added to the right-bottom of ie. Does anybody know how to implement that?
Very appreciate for any reply.
Jie
|
|
|
|
|
Hi All,
I want to grab a page using WebBrowser Control (see code below). I try to get the page content through DocumentText property in "DocumentCompleted" event handler, but it seems that the event won't be triggered. The "Navigated" event won't be triggered either. However, the "Navigating" event does.
I used to use HttpWebRequest/HttpWebResponse to grab webpage content, however, the drawback is that I can't get the full loaded page through it. What I mean by this is that maybe some javascript will execute to modify elements on the page after it's loaded, I call this page as full loaded page. I think using WebBrowser Control can overcome this drawback. It's just like a browser, and it'll execute those javascript after loading the page. But I can't make this control work correctly. Could anyone help me? I'm very appreciate.
Thanks
Jie
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static WebBrowser wb;
[STAThread]
static void Main(string[] args)
{
Go();
}
private static void Go()
{
wb = new WebBrowser();
wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted);
wb.Navigating +=new WebBrowserNavigatingEventHandler(wb_Navigating);
wb.Navigated += new WebBrowserNavigatedEventHandler(wb_Navigated);
wb.Navigate("http://www.google.com");
Console.ReadLine();
}
static void wb_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
Console.WriteLine("Navigating");
}
static void wb_Navigated(object sender, WebBrowserNavigatedEventArgs e)
{
Console.WriteLine("Navigated");
}
static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
Console.WriteLine("DocumentCompleted");
Console.WriteLine(wb.DocumentText);
}
}
}
|
|
|
|
|
Hello
Please don't take any offence when I say it's a very bad piece of code you got there!! Really! You got to declare your Webbrowser as a member of your forms class. And why the console if you got a browser on a form?!! Not to mention the main method!! You don't want to display it make visible = false; but I don't think it will ever load anything this way?!! The WebBrowser object dies the moment this Go method finishes, that's why it doesn't load anything.
To make the webbrowser really works:
1- Make a form and put it on it -even if invisible- using the toolbox
2- Handle the DocumentCompleted event, it does fire.
3- If you don't want to handle it, you can handle ProcessChanged event
There is a workaround to make Webbrowser work on console but I don't recommend it!!
Regards
|
|
|
|
|
You don't need the web browser to do that. Just do the following:
public string GetWebPage(string url)
{
HttpWebRequest webRequest = null;
HttpWebResponse webResponse = null;
Stream responseStream = null;
Encoding encode = null;
StreamReader webPageStream = null;
string webPageText = "";
try
{
webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
webResponse = (HttpWebResponse)webRequest.GetResponse();
responseStream = webResponse.GetResponseStream();
encode = Encoding.GetEncoding("utf-8");
webPageStream = new StreamReader(responseStream, encode);
webPageText = webPageStream.ReadToEnd();
}
catch (Exception e)
{
MessageBox.Show("Error : " + e.Message);
}
finally
{
if (webPageStream != null)
{
webPageStream.Close();
webPageStream.Dispose();
}
if (responseStream != null)
{
responseStream.Close();
responseStream.Dispose();
}
if (webResponse != null)
{
webResponse.Close();
}
}
return webPageText;
}
|
|
|
|
|
We managed to workaround previous problem (http://www.codeproject.com/script/comments/forums.asp?msg=1665538&forumid=1649&mode=all&userid=1533852#xx1665538xx) with Nader help, but now, another problem.
Now it's a problem to pass the address of structure array.
My colleague and I developing a program. He is dealing with unmanaged code and Iam dealing with managed code.
So we tried this:
public static extern uint bbox_table_get(uint parent_id, uint struct_size, ref Array data, ref StringBuilder data_name);
Array data = Array.CreateInstance(typeof(bb.DATA), count);
bbox_table_get(id, (uint)Marshal.SizeOf(typeof(DATA)), ref data, ref data_name);
and this:
public static extern uint bbox_table_get(uint parent_id, uint struct_size, ref DATA []data, ref StringBuilder data_name);
DATA []data = new DATA[count];
bbox_table_get(id, (uint)Marshal.SizeOf(typeof(DATA)), ref data, ref data_name);
and don't work.
We can compile in both cases, but program breaks before he get to dll.
In C++ it should be like:
UINT bb_table_get(UINT parent_id, UINT struct_size, DATA *data, wchar_t *data_name);
DATA *data = new DATA[count];
bbox_table_get(id, sizeof(DATA), data, data_name);
And DATA struct looks like:
<pre
public struct="" data
{
="" public="" uint="" data_id;
="" data_type;
public="" data_size;
};<="" pre="">
Thanks.
-- modified at 21:25 Thursday 14th September, 2006
|
|
|
|
|
Hello
First, arrays in C# are actualy references. So try to keep it simple first:
public static extern uint bbox_table_get(uint parent_id, uint struct_size, bb.DATA[], ref StringBuilder data_name);
bb.DATA[] data = new bb.DATA[count];
bbox_table_get(id, (uint)Marshal.SizeOf(typeof(DATA)), data, ref data_name);
...see if that works! If it doesn't, what is exactly the error message?
Regards
|
|
|
|
|
This is it...
It works.
Thank you.
|
|
|
|
|
I have another problem. Sorry for this problem frequency.
public static extern uint bbox_table_get(uint parent_id, uint struct_size, DATA []data, char []data_name);
DATA []data = new DATA[count];
bbox_table_get(id, (uint)Marshal.SizeOf(typeof(DATA)), data, data_name);
We can compile it with this, program call a dll function, data addresses are all OK and dll fills all data, but, for some reason, at the ending of the function, data arent sent to the application.
Data are sent as constants, accually read-only.
how can I avoid this?
Thanks...
|
|
|
|
|
Hello
Replying to your message won't send me any email notification of your post. If I weren't browsing old posts I wouldn't have noticed that you had this question.
Anyway, about your issue now.
Kasic Slobodan wrote: dll fills all data
Then...
Kasic Slobodan wrote: data arent sent to the application
Then
Kasic Slobodan wrote: Data are sent as constants, accually read-only
I must admit I'm lost!! Data are sent or not? and what do you mean by constant? What happens when you try to manipulate that data?
Regards
|
|
|
|
|
Nader Elshehabi wrote: Replying to your message won't send me any email notification of your post. If I weren't browsing old posts I wouldn't have noticed that you had this question.
I didn't realised this. Thanks for the info and sorry.
Iam lost too. I didn't understand my colleague quite well.
Anyway, he said to told you that data is not returned from dll to the application.
Hope this is more understandable...
|
|
|
|
|
1- Change the declaration of the import to:
public static extern uint bbox_table_get(uint parent_id, uint struct_size, [MarshalAs(UnmanagedType.SafeArray)] bb.DATA[] data, ref StringBuilder data_name);
2- If it didn't work try to put some data in your array's first element before sending it, and see if the data is the same or was it changed.
Regards
|
|
|
|
|
My colleague said:
I can’t send data_name as ref StringBuilder because I get some error when function is called and it works fine if I use char []data_name so please don’t focuse on that.
[MarshalAs(UnmanagedType.SafeArray)] did not help
When I said that data is sent as const I meant that data is sent from application to dll like it’s a const and because of it, data is not returned from dll.
Because I don’t speak English very good I’ll give you an example:
DATA []data = new DATA[count];
data[0].id = 20;
char []data_name = new char[data_size];
data_name[0] = ‘t’;
data_name[1] = ‘e’;
data_name[2] = ‘s’;
data_name[3] = ‘t’;
bbox_table_get(id, (uint)Marshal.SizeOf(typeof(DATA)), data, data_name);
data[0].id = 5;
data_name[0] = ‘b’;
data_name[1] = ‘r’;
data_name[2] = ‘e’;
data_name[3] = ‘s’;
data_name[4] = ‘t’;
Now when function returns back from dll:
-- modified at 9:48 Monday 18th September, 2006
|
|
|
|
|
Hi All,
I have a web application and I would like to download video files i.e. .flv or .wmv files from a web site, for example, youtube or google programmatically in my c# code. If you know how to do this please respond to this message. I appreciate your help. Thanks.
-- modified at 19:23 Thursday 14th September, 2006
|
|
|
|
|
Are you saying you want to offer video files to be viewed on your website, direct from your web servers hard drive? Or a way to retrieve video files from google video and YouTube to be used in your application some how?
Sunday Ironfoot
www.dominicpettifer.co.uk (work in progress)
|
|
|
|
|
Similar to something I posted a few messages up... you'll want to modify this to be a bit more asynchronous, especially if you're downloading large files like videos. This function downloads the contents of the web file and stores it in a temp file and returns the temp file name.
public string GetWebFile(string url)
{
HttpWebRequest webRequest = null;
HttpWebResponse webResponse = null;
Stream responseStream = null;
FileStream fileStream = null;
string filename = "";
try
{
webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
webResponse = (HttpWebResponse)webRequest.GetResponse();
responseStream = webResponse.GetResponseStream();
filename = Path.GetTempFileName();
fileStream = new FileStream(filename, FileMode.Append);
int bytesRead = 0;
byte[] data = new byte[1000];
do
{
bytesRead = responseStream.Read(data, 0, 1000);
fileStream.Write(data, 0, bytesRead);
}
while (bytesRead > 0);
}
catch (Exception e)
{
MessageBox.Show("Error : " + e.Message);
}
finally
{
if (fileStream != null)
{
fileStream.Close();
fileStream.Dispose();
}
if (responseStream != null)
{
responseStream.Close();
responseStream.Dispose();
}
if (webResponse != null)
{
webResponse.Close();
}
}
return filename;
}
|
|
|
|
|