|
I found the solution.
<br />
Uri uri = new Uri(element.GetAttribute("src"));<br />
string filePath = HttpUtility.UrlDecode(uri.AbsolutePath);<br />
Thank you.
|
|
|
|
|
I wanted to have milliseconds component being added to my DateTime object. It only returns dateTime till seconds. How can i get milliseconds.
DateTime currentDate = DateTime.Now // this statement returns time upto seconds
How can i get milliseconds?????
Thanks in advance
Praveen Raghuvanshi
Software Engineer,
|
|
|
|
|
Try:
DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:ff");
hope this helps
V.
If I don't see you in this world, I'll see you in the next one... And don't be late. (Jimi Hendrix)
|
|
|
|
|
V. wrote: DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:ff");
That only goes to centiseconds.
|
|
|
|
|
you can go up until fraction 7 ( so "fffffff")
|
|
|
|
|
Thanks a lot.....
Praveen Raghuvanshi
Software Engineer
|
|
|
|
|
praveen raghuvanshi wrote: I wanted to have milliseconds component being added to my DateTime object. It only returns dateTime till seconds. How can i get milliseconds.
DateTime currentDate = DateTime.Now // this statement returns time upto seconds
How can i get milliseconds?????
The milliseconds component is in there. Is your question about storing to millisecond accuracy, or getting the current time to millisecond accuracy?
A DateTime object can store to milliseconds. e.g.
Console.WriteLine("Now: {0}", DateTime.Now.ToString("HH:mm:ss.fff");
|
|
|
|
|
Thanks for ur effort, i got my answer
Praveen Raghuvanshi
Software Engineer,
Wins Infotek Pvt. LTd.
Technopark, Trivandrum
India.
|
|
|
|
|
Hi,
Iam trying to verify a user account present in the local computer using DirectoryEntry.
The code is as given below:
public bool TestUserLoginInComputer(string userNamePath, string userPassword)
{
try
{
DirectoryEntry myUser = new DirectoryEntry(string.Format("WinNT://" + _machineName + "/" + userNamePath + ", user"),userNamePath, userPassword);
if (myUser != null)
{
mname = admin.Name;
mypath = admin.Path;
return true;
}
else
{ return false; }
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Iam getting an exception saying "Logon failure: unknown user name or bad password.". Even though I hav given correct username and password. I hav checked with several accounts, but same problem.
Please sumone cud help me out .
Thanks in advance.
Martin
|
|
|
|
|
Hi,
I get this error: ArgumentOutOfRangeException
In this line:
this.Invoke(new DelA(delegateA), new object[] { s });
This is the environment of this code:
void delegateA(string s)
{
if (this.InvokeRequired)
{
this.Invoke(new DelA(delegateA), new object[] { response });
}
}
I've tried a few things to fix this, but im running out of suggestions.
Any suggestions anyone?
Thanks in advance!
|
|
|
|
|
Hello,
Is "response" a string?
Does youre DelA have an string parameter too?
Martin
|
|
|
|
|
Hi,
Yes on both questions.
|
|
|
|
|
Hello,
Could you post the full code of youre method and the delegate?
Martin
|
|
|
|
|
Hi,
I get this error in run time, by the way.
Here is the code:
void delegateA(string s)
{
if (this.InvokeRequired)
{
this.Invoke(new DelA(delegateA), new object[] { s });
}
else
{
if (this.itemscounter < this.totalitems)
{
this.itemscounter++;
}
}
}
This is the code where the the delegate listens to:
if (this.DelA != null)
{
this.DelA(this.bufferofserialport);
}
When i change the "< this.totalitems" to "< this.totalitems - 1", its not showing up the error.
But than its not completing till the end of the items in my listbox.
Thanks in advance!
|
|
|
|
|
Hello,
Are you using "itemscounter" for an access of an array somewhere?
for example:
xxx[itemscounter]
or
for(int i=0;i<=itemscounter;i++){ xxx[i]....)
Martin
|
|
|
|
|
Hi,
yes an ArrayList.
I filled the array with items with the for statement.
And using it now like xxx[itemscounter].
And in the if statement i go to the next item in the array.
|
|
|
|
|
Hello,
So it looks like the problem is here.
I guess if you depug the for statement you maybe find out that you whant to access a index which is out of range.
Maybe you just have to change some code from:
for(int x=0;x<=y;x++)
to:
for(int x=0;x<y;x++)
Hope that helps!
All the best,
Martin
|
|
|
|
|
I'm trying to find good example for DataGrid (could be with DataSet example) with local database... I do not want example with SQLserver (which I have seen in many 'net sites), just local database.
Thanks!
|
|
|
|
|
What type of database is your local database?
|
|
|
|
|
I'm looking into simple 2 columns (name of variable, and Interpreted Data)... the interpreted data would be the translation of the raw hex data from a raw data line on file. Since that there are many lines (could be up to 3000 lines in all), wonder if I could set up the dataset to work with datagrid so i can view the data page by page by clicking "next" button?
Hope that clears up.
|
|
|
|
|
I am beginning to understand what your datasource is / looks like. Could you please send me an example of a row of data or two rows of data and I am sure I can assist you.
|
|
|
|
|
Ok.. to clarify what the datasource looks like... (both are string value).
I'm not sure how to set up the dataset so i can look on the next set of data.
from the first row of raw data would have:
Name Interpreted_Value
Color_Used Cyan
Install_Date 12/21/99
Error_Code 848-323
Next row from raw data:
Name Interpreted_Value
Color_Used Magenta
Install_Date 3/21/93
Error_Code 239-772
Next row from raw data:
Name Interpreted_Value
Color_Used Magenta
Install_Date 1/2/03
Error_Code None
|
|
|
|
|
The data in file C:\DataSource.txt from code Looks exactly like below....
Magenta,1/2/03,XDSDF
Blue,1/2/05,None
//I know this is kind of messy but i just slapped it together. let me know if you have any questions.
StreamReader s;
string[] columns = {"Color_Used","Install_Date","Error_Code"};
DataSet ds = new DataSet();
grvMain.DataSource = ds;
ds.Tables.Add("tblMain");
for (int i = 0; i < columns.Length; i++)
{
ds.Tables["tblMain"].Columns.Add(columns[i]);
}
string sFieldDelimiter = ",";
string sRowDelimiter = "\r\n";
s = new StreamReader(@"C:\DataSource.txt");
string sAllData = s.ReadToEnd();
string[] sRowsColSplit = sAllData.Split(sRowDelimiter.ToCharArray());
foreach (string row in sRowsColSplit)
{
if (row != "")
{
string[] rows = row.Split(sFieldDelimiter.ToCharArray());
ds.Tables["tblMain"].Rows.Add(rows);
}
}
grvMain.DataBind();
|
|
|
|
|
I have a collection (IList) of custom objects bound to a DataGridView. When you click on the * line to create a new row the DataGridView automatically creates a new object for you to edit. When it does this it calls the default constructor. What I would like to do is intercept this process so that I can either call a different constructor or else do some extra initialization before the DataGridView tries to bind to it. Is there a way to do this? The RowsAdded and UserAddedRow event both fire too late. Which method is the DataGridView calling to create a new row? I don't think it's actually getting added to the collection until the user edits the row.
Thanks
|
|
|
|
|
One approach is to add a handler for the BindingSource's AddingNew event. E.g.:
InitializeGrid()
{
List<CustomItem> sourceList = new List<CustomItem>();
CustomItem firstItem = new CustomItem("Special content");
sourceList.Add(firstItem);
CustomItem nextItem = new CustomItem();
sourceList.Add(nextItem);
BindingSource bindingSource = new BindingSource();
bindingSource.DataSource = sourceList;
bindingSource.AddingNew += new AddingNewEventHandler(bindingSource_AddingNew);
dataGridView.DataSource = bindingSource;
}
private void bindingSource_AddingNew(object sender, AddingNewEventArgs e)
{
e.NewObject = new CustomItem("Not default content");
}
An alternative is to use the DataGridView's DefaultValuesNeeded event, but the object has already been constructed by the time this event fires.
|
|
|
|