|
|
Hello everyone,
I am developing an Http client which could collect data from external web sites. Currently, I want to test with the web sites which needs certificate to access (either needs client to accept its certificate or needs client to provide client's certificate).
I am suffering from finding a number of such web sites, could anyone provide some such types of web sites please?
(most web site I investigated are using ActiveX control to provide secure access, not using certificate)
thanks in advance,
George
|
|
|
|
|
George_George wrote: I am suffering from finding a number of such web sites, could anyone provide some such types of web sites please?
You mean HTTPS? Then just prefix CP's url
|
|
|
|
|
Thanks leppie,
Three more questions,
1. when using https, always using certificate? If yes, does it mean using client's certificate or using server's certificate?
2. when accessing a web site, how can see which certificate is using, e.g. when accessing hotmail?
3. What do you mean "CP's url"?
regards,
George
|
|
|
|
|
Hi,
can we create POP server of our own? How can we use the POP server to read messages from a Mail Box?
Thanks and regards,
Kathir
|
|
|
|
|
kathiresanmoorthy wrote: can we create POP server of our own?
Do you mean a mail server that supports the POP3 protocol?
kathiresanmoorthy wrote: How can we use the POP server to read messages from a Mail Box?
The question doesn't really make sense. You use the POP3 protocol to access the messages of an account on the mail server.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi i am having lot of tables in my dataset...,
Based on datatable first row first cell i am creating folder and creating excel file and export my datatble to that excel file...,
Everything is going on well...,
But during this perios lot of alert msg coming from excel side:
Do you want to save changes in "Book 61"
Like this upt o Book 73 or 73...,
Its coming on each folder creation time...,
This is my code:
for (int i = 0; i < DS.Tables.Count - 1; i++)
{
oXL = new Microsoft.Office.Interop.Excel.Application();
oWB = oXL.Workbooks.Add(System.Reflection.Missing.Value);
oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;
oRng = oSheet.Cells;
oSheet.Activate();
try
{
foreach (DataRow dr1 in DS.Tables[i].Rows)
{
foreach (DataRow dr2 in DS.Tables[i + 1].Rows)
{
if (dr1["MID"].ToString() == dr2["MID"].ToString())
{
DirectoryInfo dr = new DirectoryInfo("C:\\Test\\" + dr1["MID"].ToString() + @"\");
if (!dr.Exists)
{
dr.Create();
System.Data.DataTable dtToExport = DS.Tables[i];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
else
{
System.Data.DataTable dtToExport = DS.Tables[i + 1];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
}
else
{
DirectoryInfo dr = new DirectoryInfo("C:\\Test\\" + dr2["MID"].ToString() + @"\");
if (!dr.Exists)
{
dr.Create();
System.Data.DataTable dtToExport = DS.Tables[i + 1];
//oSheet.Activate();
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
else
{
System.Data.DataTable dtToExport = DS.Tables[i];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
}
}
}
}
catch (Exception theException)
{
MessageBox.Show(theException.ToString(), "Error");
}
}
Plz guideme whats wrong in that?
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
Try this change in bold
oXL = new Microsoft.Office.Interop.Excel.Application();
oWB = oXL.Workbooks.Add(System.Reflection.Missing.Value);
oXl.DisplayAlerts = false;
oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;
oRng = oSheet.Cells;
oSheet.Activate();
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi Everyone,
I ve one Desktop application and I ve created its setup project also.
In setup project I ve added a dialog box(TextBoxes (A)) before Welcome screen and
used Custom Action.
The problem is when setup starts, the default focus in on Next button.
I want the focus in TextBox.
Is there any way to do it?
Regards,
SIFAR.
|
|
|
|
|
i m using unsafe code in my function like this...
public unsafe void swap(int* p_x, int* p_y)
{
int temp = *p_x;
*p_x = *p_y;
*p_y = temp;
}
but when I compile my application i get error
"Unsafe code may only appear if compiling with /unsafe"
please help me
|
|
|
|
|
Go to :
Project -> Properties -> Build -> Allow Unsafe Code
|
|
|
|
|
|
hi
plz tell me the way to convert the Bitmap object to ByteArray in C#?
I don't want to use the Memory stream as it causes problem with my System memory.
reply me ASAP
Regardz
Shanzay
|
|
|
|
|
try:
bitmap.Save("picture.bmp");
byte[] data = File.ReadAllBytes("picture.bmp");
|
|
|
|
|
DeepOceans wrote: plz tell me the way to convert the Bitmap object to ByteArray in C#?
Do you want the object serialised, the raw image data, or compressed as an image format?
DeepOceans wrote: I don't want to use the Memory stream as it causes problem with my System memory.
What kind of problem?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You should find out what problem using a MemoryStream is causing, because there shouldn't be any.
And i thought that first reply was a good way to get it into a byte array without using a stream in memory (which would probably be the best solution)
Apart from that you could write the data yourself, reading the colour of each pixel and then writing this data into an array - of course you'd need to check the bit-depth of the image and make sure you write the data correctly, plus you'd probably want to write the bitmap header as well... it's a fair bit of effort.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Use a LockBits method.
You should get something like this:
unsafe static byte[] getBytes(BitmapData data)
{
byte* firstByte = (byte*)data.Scan0.ToPointer();
int size = data.Stride * data.Height;
byte[] bytes = new byte[size];
for (int i = 0; i < size; i++)
bytes[i] = firstByte[i];
return bytes;
}
unsafe static void setBytes(BitmapData data, byte[] bytes)
{
byte* firstByte = (byte*)data.Scan0.ToPointer();
int size = data.Stride * data.Height;
for (int i = 0; i < size; i++)
firstByte[i] = bytes[i];
}
static void Main()
{
using (Bitmap bmp = (Bitmap)Bitmap.FromFile(@"test.bmp")) {
BitmapData data = bmp.LockBits(new Rectangle(new Point(0), bmp.Size),
ImageLockMode.ReadOnly, bmp.PixelFormat);
byte[] bytes = getBytes(data);
bmp.UnlockBits(data);
using (Bitmap copy = new Bitmap(data.Width, data.Height, bmp.PixelFormat)) {
data = copy.LockBits(new Rectangle(new Point(0), copy.Size),
ImageLockMode.WriteOnly, copy.PixelFormat);
setBytes(data, bytes);
copy.UnlockBits(data);
copy.Save(@"test - copy.bmp");
}
}
}
Compile with /unsafe .
This code copies a BMP file. Insted getBytes and setBytes you may want to use System.Runtime.InteropServices.Marshal.Copy method, but it has many function we don't need here so it's better to stick to a simplier version.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Hi I've used the following Code to read Mail from a pop server In the UI when I enter the Server name as "smtpx14.msoutlookonline.net" and username as "X" and Password as "Confindent", it says the status as "220 exsmtp014-3.exch014.msoutlook.online.net Microsoft ESMTP MAIL Service, Version: 6.0.3790.3959 ready at mon 21 jul 08 22:29
530 5.7.0 must issue a STARTTLS command first
530 5.7.0 must issue a STARTTLS command first
530 5.7.0 must issue a STARTTLS command first "
could some one assist me in fixing this out
Code:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Web.Mail;
namespace POPapp
{
///
/// Summary description for Form1.
///
public class POPForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.TextBox POPServ;
private System.Windows.Forms.TextBox User;
private System.Windows.Forms.TextBox Passw;
private System.Windows.Forms.RichTextBox Message;
private System.Windows.Forms.Button ConnectBtn;
private System.Windows.Forms.Button DisconnectBtn;
private System.Windows.Forms.ListBox Status;
private System.Windows.Forms.Button RetrieveBtn;
private System.Windows.Forms.TextBox Number;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public POPForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Number = new System.Windows.Forms.TextBox();
this.Status = new System.Windows.Forms.ListBox();
this.label4 = new System.Windows.Forms.Label();
this.Message = new System.Windows.Forms.RichTextBox();
this.label6 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.ConnectBtn = new System.Windows.Forms.Button();
this.POPServ = new System.Windows.Forms.TextBox();
this.User = new System.Windows.Forms.TextBox();
this.DisconnectBtn = new System.Windows.Forms.Button();
this.Passw = new System.Windows.Forms.TextBox();
this.RetrieveBtn = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// Number
//
this.Number.Location = new System.Drawing.Point(80, 296);
this.Number.Name = "Number";
this.Number.Size = new System.Drawing.Size(56, 20);
this.Number.TabIndex = 12;
this.Number.Text = "";
//
// Status
//
this.Status.Location = new System.Drawing.Point(8, 344);
this.Status.Name = "Status";
this.Status.Size = new System.Drawing.Size(392, 56);
this.Status.TabIndex = 16;
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 96);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 16);
this.label4.TabIndex = 7;
this.label4.Text = "Message";
//
// Message
//
this.Message.Location = new System.Drawing.Point(8, 112);
this.Message.Name = "Message";
this.Message.Size = new System.Drawing.Size(392, 176);
this.Message.TabIndex = 6;
this.Message.Text = "";
this.Message.WordWrap = false;
//
// label6
//
this.label6.Location = new System.Drawing.Point(8, 328);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(100, 16);
this.label6.TabIndex = 15;
this.label6.Text = "Status";
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 16);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "POP Server";
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 40);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "User";
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 64);
this.label3.Name = "label3";
this.label3.TabIndex = 2;
this.label3.Text = "Password";
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 296);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(80, 16);
this.label5.TabIndex = 11;
this.label5.Text = "Mail Number";
//
// ConnectBtn
//
this.ConnectBtn.Location = new System.Drawing.Point(328, 16);
this.ConnectBtn.Name = "ConnectBtn";
this.ConnectBtn.TabIndex = 8;
this.ConnectBtn.Text = "Connect";
this.ConnectBtn.Click += new System.EventHandler(this.ConnectBtn_Click);
//
// POPServ
//
this.POPServ.Location = new System.Drawing.Point(80, 16);
this.POPServ.Name = "POPServ";
this.POPServ.Size = new System.Drawing.Size(224, 20);
this.POPServ.TabIndex = 3;
this.POPServ.Text = "pop.server.com";
//
// User
//
this.User.Location = new System.Drawing.Point(80, 40);
this.User.Name = "User";
this.User.Size = new System.Drawing.Size(224, 20);
this.User.TabIndex = 4;
this.User.Text = "user";
//
// DisconnectBtn
//
this.DisconnectBtn.Enabled = false;
this.DisconnectBtn.Location = new System.Drawing.Point(328, 48);
this.DisconnectBtn.Name = "DisconnectBtn";
this.DisconnectBtn.TabIndex = 9;
this.DisconnectBtn.Text = "Disconnect";
this.DisconnectBtn.Click += new System.EventHandler(this.DisconnectBtn_Click);
//
// Passw
//
this.Passw.Location = new System.Drawing.Point(80, 64);
this.Passw.Name = "Passw";
this.Passw.PasswordChar = '*';
this.Passw.Size = new System.Drawing.Size(224, 20);
this.Passw.TabIndex = 5;
this.Passw.Text = "password";
//
// RetrieveBtn
//
this.RetrieveBtn.Enabled = false;
this.RetrieveBtn.Location = new System.Drawing.Point(152, 296);
this.RetrieveBtn.Name = "RetrieveBtn";
this.RetrieveBtn.TabIndex = 10;
this.RetrieveBtn.Text = "Retrieve";
this.RetrieveBtn.Click += new System.EventHandler(this.RetrieveBtn_Click);
//
// POPForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(408, 405);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.Status,
this.label6,
this.Number,
this.label5,
this.RetrieveBtn,
this.DisconnectBtn,
this.ConnectBtn,
this.label4,
this.Message,
this.Passw,
this.User,
this.POPServ,
this.label3,
this.label2,
this.label1});
this.MaximizeBox = false;
this.Name = "POPForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Download Mail via POP3";
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new POPForm());
}
private void ConnectBtn_Click(object sender, System.EventArgs e)
{
// change cursor into wait cursor
Cursor cr = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
// create server POP3 with port 110
Server = new TcpClient(POPServ.Text,25);
Status.Items.Clear();
try
{
// initialization
NetStrm = Server.GetStream();
RdStrm = new StreamReader(Server.GetStream());
Status.Items.Add(RdStrm.ReadLine());
// Login Process
Data = "USER " + User.Text + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Status.Items.Add(RdStrm.ReadLine());
Data = "PASS " + Passw.Text + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Status.Items.Add(RdStrm.ReadLine());
// Send STAT command to get information ie: number of mail and size
Data = "STAT" + CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData, 0, szData.Length);
Status.Items.Add(RdStrm.ReadLine());
// change enabled - disabled button
ConnectBtn.Enabled = false;
DisconnectBtn.Enabled = true;
RetrieveBtn.Enabled = true;
// back to normal cursor
Cursor.Current = cr;
}
catch (InvalidOperationException err)
{
Status.Items.Add("Error: " + err.ToString());
MessageBox.Show(err.Message);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message);
}
}
private void DisconnectBtn_Click(object sender, System.EventArgs e)
{
// change cursor into wait cursor
Cursor cr = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
// Send QUIT command to close session from POP server
Data = "QUIT"+CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
Status.Items.Add(RdStrm.ReadLine());
//close connection
NetStrm.Close();
RdStrm.Close();
// change enabled - disabled button
ConnectBtn.Enabled = true;
DisconnectBtn.Enabled = false;
RetrieveBtn.Enabled = false;
// back to normal cursor
Cursor.Current = cr;
}
private void RetrieveBtn_Click(object sender, System.EventArgs e)
{
// change cursor into wait cursor
Cursor cr = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
string szTemp;
Message.Clear();
try
{
// retrieve mail with number mail parameter
Data = "RETR "+ Number.Text+CRLF;
szData = System.Text.Encoding.ASCII.GetBytes(Data.ToCharArray());
NetStrm.Write(szData,0,szData.Length);
szTemp = RdStrm.ReadLine();
if(szTemp[0]!='-')
{
while(szTemp!=".")
{
Message.Text += szTemp+CRLF;
szTemp = RdStrm.ReadLine();
}
}
else
{
Status.Items.Add(szTemp);
}
// back to normal cursor
Cursor.Current = cr;
}
catch(InvalidOperationException err)
{
Status.Items.Add("Error: "+err.ToString());
}
}
public TcpClient Server;
public NetworkStream NetStrm;
public StreamReader RdStrm;
public string Data;
public byte[] szData;
public string CRLF = "\r\n";
}
}
Thanks in Advance.......
Regards,
Kathir
|
|
|
|
|
Post the relevant code, not the entire project.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hii..i have sqldatabase from which the data is being displayed in gridview fields and i am performing edit delete operations using the link buttons.and finally i want to dispaly the record of a single row in color format but i am unable to do so.and gridview fields are boun ddata fields.plz help me out.
santosh
|
|
|
|
|
You can use the "RowCreated" event to find the row and set background color.
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = GridView1.DataKeys[e.Row.RowIndex].ToString();
if (id = "test")
{
e.Row.BackColor = "pink";
}
}
}
|
|
|
|
|
Hello everyone,
Suppose I have an URL, and I want to get the domain part, for example, URL is, http://abc.com/some/address/abc.html, the domain is abc.com.
My questions are,
- Are there any existing utility class to do this? Not all URLs begins with protocol part, like http://, and not all ends with /, so I feel hard when I try to write a parser by myself;
- Is domain case sensitive or not? i.e. abc.com the same as ABc.Com?
thanks in advance,
George
|
|
|
|
|
Domains aren't case sensitive. abc.com is the same as ABc.Com. If you're comparing, just lower case it.
Use a regular expression for the domain part. Protocol doesn't matter. You're just interested in the domain name. From there, you can build a URL and validate it. Anything after a / is content, as per your example.
|
|
|
|
|
Thanks Bert!
Are there any existing regular expression to make a reference? I think it should be a common problem.
regards,
George
|
|
|
|
|
George_George wrote: Are there any existing utility class to do this? Not all URLs begins with protocol part, like http://, and not all ends with /, so I feel hard when I try to write a parser by myself;
Yes. System.Net.Uri class does this.
Uri uri = new Uri("http://abc.com/some/address/abc.html");
Console.WriteLine(uri.Host);
George_George wrote: Is domain case sensitive or not? i.e. abc.com the same as ABc.Com?
Usually domains are not case sensitive. But some web servers like APACHE, consider the folder names as case sensitive. Which means, www.abc.com will be equal to www.ABC.com , but www.abc.com/somefolder won't be equal to www.abc.com/SomeFolder according to apache.
|
|
|
|
|