|
|
Eddy Vluggen wrote: I prefer to return "null"
How would a constructor do that?
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:21 AM
|
|
|
|
|
A constructor wouldn't, the factory-method that I meant to refer to would
I are troll
|
|
|
|
|
In my opinion, no. .Net will reclaim the resources even if the exception occurs in constructor.
I found this[^] article and found decent. I did not read it thoroughly though.
|
|
|
|
|
Cool. That's me convinced. Exceptions in constructors is fine then. Thanks!
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: Exceptions in constructors is fine then
Of course. .NET does it all the time, have a look at FileInfo constructor e.g.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:21 AM
|
|
|
|
|
Hi All,
I have some text (original message) as follows
<i>please see below. i will send another one where its coming on top of the email</i>
I am capturing this text in the mail_forward event in a string
I added some more text (<b>current text</b> which is combination of original message and some more new text)
In the Item_Send event I want to know the index of original message in the current text.
The problem is when I print current text it is as follows
<div>
<p class=MsoNormal>please see below. i will send another one where its coming on top of the email<o:p></o:p></p>
</div>
from where these extra lines and <p> tags <o:p> tags are coming? for this reason
I am unable to find original message in the current text. i.e. I want to find the index of original message in the new text. Can anyone tell me how to do this in c#
Thanks
Sridhar
|
|
|
|
|
hi,
This is mitesh doing engineering in IT. I need help do to the project for finding out the IP Address on LAN. The code must be in C# preferably.
If you can help please mail the code at mitesh_487@rediffmail.com
thank you,
please do it urgently.
|
|
|
|
|
|
namespace NKUtilities
{
using System;
using System.Net;
public class DNSUtility
{
public static int Main (string [] args)
{
String strHostName = new String ("");
if (args.Length == 0)
{
strHostName = Dns.GetHostName ();
Console.WriteLine ("Local Machine's Host Name: " + strHostName);
}
else
{
strHostName = args[0];
}
IPHostEntry ipEntry = DNS.GetHostByName (strHostName);
IPAddress [] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
Console.WriteLine ("IP Address {0}: {1} ", i, addr[i].ToString ());
}
return 0;
}
}
}
|
|
|
|
|
Jack - you're it is not recommended that you feed these idiots with code, see d@nishes post, it is quite relevant.
Heaping scorn is a more appropriate answer. Giving a clue to where to look is even better eg point the idiot to the using System.Net; library, feeding an idiot code only encourages them.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
This way you are not helping the poster to learn. Hence I voted you down.
|
|
|
|
|
mitesh_487 wrote: This is mitesh doing engineering in IT.
And soon you will be working for some IT company without any knowledge. And flooding forums with "send me code" type questions.
mitesh_487 wrote: I need help do to the project for finding out the IP Address on LAN. The code must be in C# preferably.
Is this what you call help?
mitesh_487 wrote: If you can help please mail the code at mitesh_487@rediffmail.com
Great going. What do you expect to learn like this?
|
|
|
|
|
d@nish wrote:
mitesh_487 wrote:
If you can help please mail the code at mitesh_487@rediffmail.com
Great going. What do you expect to learn like this?
How to receive spam.
|
|
|
|
|
Hi
Can you tel me what does this error signify?
'ListView.Form1' already defines a member called 'InitializeComponent' with the same parameter types
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace ListView
{
public partial class Form1 : Form
{
XmlTextReader reader;
XmlDocument doc = new XmlDocument();
StringCollection foldercol = new StringCollection();
ImageList ilLarge = new ImageList();
ImageList ilSmall = new ImageList();
private System.Windows.Forms.ListView list = new System.Windows.Forms.ListView();
Label lbl = new Label();
Button b = new Button();
public Form1()
{
InitializeComponent();
CreateHeadersAndFillListView();
String sss;
PaintListView(sss);
}
private void InitializeComponent()
{
button1.Click += new EventHandler(button1_Click);
}
private void CreateHeadersAndFillListView()
{
ColumnHeader colHead;
colHead = new ColumnHeader();
colHead.Text = "Filename";
this.list.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "Size";
this.list.Columns.Add(colHead);
colHead = new ColumnHeader();
colHead.Text = "Last accessed";
this.list.Columns.Add(colHead);
}
private void PaintListView(string sss)
{
try
{
ListViewItem lvi;
ListViewItem.ListViewSubItem lvsi;
this.lbl.Text = sss + "(Double click to display the path name)";
this.list.Items.Clear();
this.list.BeginUpdate();
reader = new XmlTextReader("path.xml");
Form1 f = new Form1();
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Text:
String s1;
s1 = reader.Value;
String ss;
ss = listBox1.SelectedItem.ToString();
sss = ss + s1;
object o3 = (object)sss;
DirectoryInfo dire = new DirectoryInfo(sss);
if (dire.Exists)
{
String[] folder;
folder = Directory.GetDirectories(sss);
foreach (string foldername in folder)
{
DirectoryInfo di = new DirectoryInfo(foldername);
if (di.Exists)
{
String[] files;
files = Directory.GetFiles(foldername);
foreach (String filename in files)
{
FileInfo fil2 = new FileInfo(filename);
lvi = new ListViewItem();
lvi.Text = fil2.Name;
lvi.ImageIndex = 1;
lvi.Tag = fil2.FullName;
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = fil2.Length.ToString();
lvi.SubItems.Add(lvsi);
lvsi = new ListViewItem.ListViewSubItem();
lvsi.Text = fil2.LastAccessTime.ToString();
lvi.SubItems.Add(lvsi);
this.list.Items.Add(lvi);
}
this.list.EndUpdate();
}
}
}
break;
}
}
}
catch (Exception err)
{
MessageBox.Show("Error: " + err.Message);
}
this.list.View = View.Details;
}
private void button1_Click(object sender, EventArgs e)
{
string[] drives = Environment.GetLogicalDrives();
foreach (string strDrive in drives)
{
listBox1.Items.Add(strDrive.ToString());
}
}
}
}
|
|
|
|
|
mrithula8 wrote: private void InitializeComponent() { button1.Click += new EventHandler(button1_Click); // list.ItemActivate += new EventHandler(list_ItemActivate); }
If you remove the above then you should be OK. In Visual Studio the components are initialized in the FORM1.Designer.cs file.
Hope this helps.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
try this
public Form1()
{
InitializeComponent1();
CreateHeadersAndFillListView();
String sss;
PaintListView(sss);
}
private void InitializeComponent1()
{
button1.Click += new EventHandler(button1_Click);
}
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L
%^]*IRXD#@GKCQ`R\^SF_WcHbORY87֦ʻ6ϣN8ȤBcRAV\Z^&SU~%CSWQ@#2
W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN%
Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-iTV.C\y<pjxsg-b$f4ia>
--------------------------------------------------------
128 bit encrypted signature, crack if you can
|
|
|
|
|
Hi Guys. I have a working Excel application that reads an input file and writes the data to an Excel sheet. Now, I need to do a few more things though but just can't seem to get it working properly. This is what I need to do and what I have so far.
I need to set the current cell color to red if the Recon Indicator is NN but it sets all the cells before the current cell to RED. My question is how do I select only the current Cell. I have tried numerous things but it doesn't work.
if (RECONCILIATIONIND == "N")
{
objSheet.Cells[iR, iC + 18] = RECONCILIATIONIND;
objRange = objSheet.Cells.Rows.EntireRow;
objRange.Font.ColorIndex = "3";
}
The next problem I have is that I need to do some calculation on an unknown number of cells and subtract it from a total in a different column. Below is a sample screen.
Nominees & Own Name (Level 1) Beneficiaries (Level 2)
19326421
175
84
76
2238
235
14
591
345
122
240
346
From the above, I need to calculate the totals in Beneficiary (level 2) and subtract that from Level 1 total and add the total into a new column. Now, there is an undertermined number of values in Level 2 i.e. there could be 2 or 4 or 50 or 300 values to add. How would I be able to do that?
Any help or advise would be appreciated.
Excellence is doing ordinary things extraordinarily well.
Excellence is doing ordinary things extraordinarily well.
modified on Tuesday, March 10, 2009 4:03 AM
|
|
|
|
|
Kwagga wrote: objSheet.Cells[iR, iC + 18] = RECONCILIATIONIND;
try modifying this to select 1 cell and then set the colour. You are setting the colour for the range not the cell.
This entire excercise is based on traversing row/column sets and identifying the values for a cell. Should be able to acheive it with a Do While loop.
Changing the format made a difference huh! Don't be rude next time.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I don't think that I was being rude. Although the pre tag was incorrectly placed it was still readable. Anyway, thanks for the help. What I have resorted to doing was instead search the sheet for value and then mark it in a different color. However, it only finds the first instance and then stops. How can I get it to search for the next instance? Below the code I have put together. A bit rough though.
Excel.Range currentFind = (Excel.Range)objSheet.Columns["S", Type.Missing];
Excel.Range firstFind = null;
currentFind = currentFind.Find("N", Type.Missing, Excel.XlFindLookIn.xlValues,
Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext,
true, Type.Missing);
while (currentFind != null)
{
if (firstFind == null)
{
firstFind = currentFind;
}
else if (currentFind.get_Address(Type.Missing, Type.Missing, Excel.XlReferenceStyle.xlA1,
Type.Missing,
Type.Missing) == firstFind.get_Address(Type.Missing, Type.Missing,
Excel.XlReferenceStyle.xlA1,
Type.Missing, Type.Missing))
{
break;
}
currentFind.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red);
currentFind = currentFind.FindNext(currentFind);
}
Any advice on the other Issue I mentioned?
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
how to get the control of the shape residing in the active cell of my sheet?
I mean to say, is there a way i can say:
Excel.Shape sh = MyApplication.ActiveCell.get_Shape(); or something like that so that I get the shape's control and further I can use it.
Regards
|
|
|
|
|
hi guys, this is my first post in CodeProject.
i want to send an email from my c# code but at a specific time.
would any one please help me.
i have exchange server in my office and i am able to send email immediately using System.Net.Mail.SmtpClient class but can't send it at a specific time.
thanks
|
|
|
|
|
Ramin RamZ wrote: this is my first post in CodeProject.
That I'm afraid is obvious from the content of the post. This question has been asked sooo many times it is ridiculious, try searching either CP or Google. You will find many examples to work with.
Good luck.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i have already searched google but didn't solve my problem.
because i dont want to put it in a queue and set a timer to look at the queue after a specific time.
the problem is that the computer sending the mail might be off on that time, what i want is to send the mail even if the computer goes off.
|
|
|
|
|
Schedule the mail sending application using windows scheduler.
Ramin RamZ wrote: the problem is that the computer sending the mail might be off on that time, what i want is to send the mail even if the computer goes off.
|
|
|
|