|
Hi all,
I am downloading a file from remote machine using webclient
as like as below,
<br />
WebClient oclient = new WebClient();<br />
<br />
oclient.DownloadFile(hostPath,localpath);<br />
1. here how can i ensure that the file is existing at the remote machine's path(hostPath) -(eg. same as like File.Exists() function ??)
2. during this operation if the file(localpath) had already opened, this download operation will throw the exception, in this case how should i show the opened file to the user.
3. During this download operation how can i detect the LAN connection failiure (disconnected )
|
|
|
|
|
1- The DownloadFile method will throw a WebException if the file does not exits. Examine the WebException's Status and Response properties.
2- Opened by the current process or another process?
3- Again, an exception will be thrown if this occurs.
You should experiment to know what exceptions are thrown in each of the cases, and what information those exceptions provide.
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
Hello
Can anyone give me a hint as to how I can override the font handling in a groupbox? I need to set the font style of a groupbox title/header to Bold, but that automatically results in all labels and other controls within the groupbox doing the same. Of course one can just set each of the childcontrols' font style to regular, but that gets more complicated when using more complex user controls/custom controls.
Therefore having the ability to set the header font of the groupbox to bold without affecting child controls is what I could need help to achieve.
Thanks!
-- modified at 9:09 Tuesday 24th October, 2006
All needed for evil to prevale is for good men to do nothing.
C
|
|
|
|
|
when i am inserting data by inline sql then i am getting error like
Server: Msg 241, Level 16, State 1, Line 1
Syntax error converting datetime from character string.
and my inline sql is :-
INSERT INTO MShift (DayName,ShiftDate,ShiftEntryDate,ShiftStartTime,ShiftEndTime,
TotHour,PositionID,Department,Rate,HospitalID)
VALUES ('Wednesday',CONVERT(VARCHAR(10),'10/04/2006',121),'NULL','1200','2100','NULL','1','2','100',1)
due to the date i am getting error so pls tell me where i am wrong and pls rectify my error.
thanx....
xzv
|
|
|
|
|
I don't understand why you are converting the date. I assume that ShiftDate is a DateTime or SmallDateTime column then you should just be able to put the date in a string and it will work.
My only suggestion is that, as a general rule, you should use the ISO format yyyy-mm-dd so that the format of the date is culture independent.
|
|
|
|
|
take the quotes off of the nulls
|
|
|
|
|
how to select the border of the picture box in run time?
plez help
|
|
|
|
|
hello everyone.
Do you have an easy way when resize my windows form, proportionally to resize all components(Picturebox, buttons,textboxes, graphics etc.)
Thanks.
|
|
|
|
|
Check out the Anchor, Fill and Dock properties of the controls...
Splitter controls can help as well.
Good luck...
|
|
|
|
|
it depends what you need. Anchor and docking can do alot, but the only way I could grow two groupboxes 50/50 in a form was by handling resize manually. Everything inside the groupboxes was handled by a combination of standard means but the 50/50 thing proved elusive.
|
|
|
|
|
Is there a way of casting a generic list to another one, best way to explain what I want is, imagine the following scenario
public class Customer : Person { ... }
public class Criminal : Person { ... } Now there's a dictionary object to provide a lookup table:
Dictionary<Type, List<Person>> lists; And I'd like this dictioanry to contain a list of Customers and Criminals so...
lists.Add(typeof(Customer), new List<Customer>());
lists.Add(typeof(Criminal), new List<Criminal>()); However this complains that there's no conversion between List<Customer> and List<Person>.
This code will be accessed later on, for arguments sake through a method like this:
public List<T> GetList<T>() where T : Person
{
return lists[typeof(T)];
}
Anybody have any ideas on how to accomplish this. The objects (Customer and Criminal) can be cast to Person and back again but it does not like casting the lists. Any ideas on "fooling" the compiler into doing what I want?
Sig cops got me...
|
|
|
|
|
I've found a work-around (not very nice but it works), declare Dictionary<Type, object> lists;
Sig cops got me...
|
|
|
|
|
You could use a Converter
<code>
List<Customer> customers = new Converter<Customer, Person>( CustomerToPerson )
private Person CustomerToPerson(Customer c)
{
return (Person)c; // More complicated I know, but you get the idea
}</code>
only two letters away from being an asset
|
|
|
|
|
I did think of something along those lines but doing that would result in potentially thousands of casts. (Maybe I'm being stupid though), but the way I'm doing it at the moment only has one cast and it's hidden in the internal implementation anyway so I'll go with that for the time being until I can think of a better way, or MS decide to fix the "problem".
Sig cops got me...
|
|
|
|
|
You cannot cast a List<customer> to List<person> because List<person> supports .Add(person), but you then you could add criminals to your customers list.
|
|
|
|
|
Yep, I agree, that's why it's complaining, but then again it won't let me add a List<Criminal> to the dictionary in the first place which would have solved these "problems".
I think that the only half-decent way around this is to use the dictionary to store object s. I just have to make sure that it never returns the wrong object to cast.
Sig cops got me...
|
|
|
|
|
Hello all, I am having a little trouble with a ListView. I am trying to update an item but it isn't doing what it should...
To explain: I have a list containing about 20 items. I can find the index location for the item I want to update. I am then removing the old item at the found index location, and then inserting the new item at the same point. It works, but with one problem...
It isn't inserting the new item at the correct index position. Instead it is putting it at the bottom of the list... And I can't work out why??
I am viewing the list in 'tile' view.
Can anybody help?
Thanks in advance,
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
Hello,
You tried already :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformslistviewlistviewitemcollectionclassinserttopic.asp
Creates a new item and inserts it into the collection at the specified index.
[C#] public ListViewItem Insert(int, string);
that doesn't work?
You have some code ?
|
|
|
|
|
Thanks for the reply...
I can insert the item. It is just not being inserted where I asked it to be...
Here is the code:
ListViewItem temp = new ListViewItem();<br />
temp = listView_main.FindItemWithText(item_text, true, 0);<br />
int location = temp.Index;<br />
<br />
ListViewItem lvItem = new ListViewItem(item_text, icon);<br />
lvItem.SubItems.Add("Name:" + name + "(" + aka + ")");<br />
lvItem.SubItems.Add("Data:" + data);<br />
lvItem.ToolTipText = item.ToString();<br />
lvItem.Group = listView_main.Groups[0];<br />
<br />
listView_main.Items.RemoveAt(location);<br />
<br />
listView_main.Items.Insert(location, lvItem);
Hope that helps...
Phil
"Rules are for the obedience of fools and the guidance of wise men"
|
|
|
|
|
namespace codepro
{
///
/// Zusammenfassung für Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.ListView TheList;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.Button button1;
///
/// Erforderliche Designervariable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Erforderlich für die Windows Form-Designerunterstützung
//
InitializeComponent();
//
// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu
//
}
///
/// Die verwendeten Ressourcen bereinigen.
///
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Vom Windows Form-Designer generierter Code
///
/// Erforderliche Methode für die Designerunterstützung.
/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
///
private void InitializeComponent()
{
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem(new string[] {
"One",
"1.2.",
"1.3.",
"1.4."}, -1);
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem(new string[] {
"Two",
"2.1.",
"2.2.",
"2.3."}, -1);
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem(new string[] {
"Four",
"4.1.",
"4.2.",
"4.3."}, -1);
this.TheList = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// TheList
//
this.TheList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.TheList.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3});
this.TheList.Location = new System.Drawing.Point(24, 16);
this.TheList.Name = "TheList";
this.TheList.Size = new System.Drawing.Size(200, 232);
this.TheList.TabIndex = 0;
this.TheList.View = System.Windows.Forms.View.List;
this.TheList.SelectedIndexChanged += new System.EventHandler(this.TheList_SelectedIndexChanged);
//
// columnHeader1
//
this.columnHeader1.Text = ":: 1 ::";
//
// columnHeader2
//
this.columnHeader2.Text = ":: 2 ::";
//
// button1
//
this.button1.Location = new System.Drawing.Point(240, 80);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(48, 64);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button1);
this.Controls.Add(this.TheList);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
///
/// Der Haupteinstiegspunkt für die Anwendung.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void TheList_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
private void button1_Click(object sender, System.EventArgs e)
{
System.Windows.Forms.ListViewItem listViewItemIns = new System.Windows.Forms.ListViewItem(new string[] {
"Three",
"3.1.",
"3.2.",
"3.3."}, -1);
TheList.Items.Insert(2,listViewItemIns);
Refresh();
}
}
}
The button1_Click inserts the Item "Three" at the correct place
So i doesn't see a mistake in you code
|
|
|
|
|
I am using a textbox which takes date of birth as input
I want to use regular expression validator for that textbox
The Date Format Should Be mm/dd/yyyy
and valid date
Can Enyone Hel me Out
|
|
|
|
|
|
You can use a Masked Textbox?
|
|
|
|
|
If you want a regex the following should work
\d{2}/\d{2}/\d{4}
Not very advanced, just checks for 2 digits followed by a slash and 2 more digits, then a slash then a group of four digits.
Sig cops got me...
|
|
|
|
|
You can use a pattern like "\d{2}/\d{2}/\d{4}" to validate only the format. You can rule out dates that clearly are invalid with a pattern like "(0[1-9]|[12]\d|3[01])/(0[1-9]|1[0-2])/(19|20)\d\d", but a pattern that would actually check if the date is valid would be extremely complex. Just imagine all the combinations to validate the correct number of days in the different months, then imagine leap years on top of that...
---
b { font-weight: normal; }
|
|
|
|
|