|
Luc Pattyn wrote: - I had some trouble with Image.FromFile keeping the file open (although the entire image
has been loaded in memory). So I decided to immediately copy the image and dispose of
the one returned by FromFile.
Yes, this is a known issue, a wrapper method that copies and closes the original is a good idea, if you may want to save over an image you've loaded and edited.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have the following code in SQL
set @newdate = datediff(second , '1970/01/01',@date) - datediff(second,getutcdate(),getdate())
Is there any way I can achieve the same result in C# at code level,,
ANy help would be much appreciated.
imran
|
|
|
|
|
DateTime date1 = DateTime.Now;
DateTime date2 = new DateTime(1970, 1, 1);
TimeSpan span = date1 - date2
Console.WriteLine(span);
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
but where do I put my date ,, notice @date is the input parameter which I input as any date ,.,,
and I also need to convert that to utcdate??
I am sorry,, I think I havent understood the code completely or you may have missed something,,,
|
|
|
|
|
Use the Subtract method of the DateTime structure to get a TimeSpan that represents the difference from 1970-01-01:
TimeSpan integral = someDate.Subtract(new DateTime(1970,1,1));
Similarly, you can get the difference between local time and UTC time:
TimeSpan diff = DateTime.UtcNow - DateTime.Now;
You can add and subtract TimeSpan values. Use the TotalSeconds property to get the number of seconds that a TimeSpan value represents.
---
Year happy = new Year(2007);
|
|
|
|
|
Many Thanks
It worked
Imran
|
|
|
|
|
Ever heard of Google[^] or CodeProject?
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
it returns to me only that ĂĂ@Ĺ•‡@˘—…““‰•‡@„‰ƒŁßœGŽśEUQŢT.
first what i doing is convert string to byte[]:
byte[] data = Encoding.GetEncoding("IBM870").GetBytes(text);
second step is your code ...
byte[] converted = Encoding.UTF8.GetBytes(Encoding.GetEncoding("latin2").GetString(data));
and now i need a string in utf ...
string newtext = Encoding.UTF8.GetString(converted);
what is wrong???
-----------------------------
Computer is my hell on earth
|
|
|
|
|
Your mistake is wuite clear. First you changed the string to bytes using the IBM870 encoding. Then you changed that bytes to a string again using the Latin2 encoding. Here is the problem.
After that when you used the UTF8 encoding to convert the bytes to string, for sure it'll screw up.
What are you tying to do anyway converting strings to bytes back and forth?
Regards
|
|
|
|
|
Continue in the same thread instead of starting a new one.
---
Year happy = new Year(2007);
|
|
|
|
|
|
If I find that I have made a mistake in a posted message how can I remove it.
|
|
|
|
|
After opening your message, click Remove to delete it or modify to update it. (on the right bottom of the message)
|
|
|
|
|
I want to write a list of all the MP3's on a drive. In this form it finds 16940 files
void DirSearch(string sDir)
{
//FileInfo t = new FileInfo(Environment.CurrentDirectory + "\\all.lst");
//StreamWriter Tex = t.CreateText();
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, "*.mp3"))
{
listBox1.Items.Add(f); // All files are found
//Tex.WriteLine(f);
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
//Tex.Close();
}
When I switch to this form it only finds 590 files
void DirSearch(string sDir)
{
FileInfo t = new FileInfo(Environment.CurrentDirectory + "\\all.lst");
StreamWriter Tex = t.CreateText();
try
{
foreach (string d in Directory.GetDirectories(sDir))
{
foreach (string f in Directory.GetFiles(d, "*.mp3"))
{
//listBox1.Items.Add(f);
Tex.WriteLine(f);
}
DirSearch(d);
}
}
catch (System.Exception excpt)
{
Console.WriteLine(excpt.Message);
}
Tex.Close();
}
|
|
|
|
|
FileInfo.CreateText Method
Creates a StreamWriter that writes a new text file.
Do you want to create a new text file on every call to DirSearch(d)?
|
|
|
|
|
Your right! Thats the problem. Tnx.
|
|
|
|
|
I've got a DataGridViewComboBoxColumn that I want to bind to a datasource. However, on load, I want the DataGridViewComboBoxColumn to display values in from the column of a table.
So I'm sort of looking at a double purpose DataGridViewComboBoxColumn: i.e When in Read mode it displays values from the tables Columns, and when in Edit mode it populates the DataGridViewComboBoxColumn with additional items.
I just cant figure out how to do this.
-- modified at 18:54 Monday 15th January, 2007
Live in fragments no longer. Only connect.
|
|
|
|
|
how can i convert string from latin2 to utf-8. its a big problem for me becouse i have deadline in monday ... please can you help me, im workink with c# in vs2005. thanks Ondrej
-----------------------------
Computer is my hell on earth
|
|
|
|
|
byte[] converted = Encoding.UTF8.GetBytes(Encoding.GetEncoding("latin2").GetString(theData));
---
Year happy = new Year(2007);
|
|
|
|
|
it returns to me only that ĂĂ@Ĺ•‡@˘—…““‰•‡@„‰ƒŁßœGŽśEUQŢT.
first what i doing is convert string to byte[]:
byte[] data = Encoding.GetEncoding("IBM870").GetBytes(text);
second step is your code ...
byte[] converted = Encoding.UTF8.GetBytes(Encoding.GetEncoding("latin2").GetString(data));
and now i need a string in utf ...
string newtext = Encoding.UTF8.GetString(converted);
what is wrong???
-----------------------------
Computer is my hell on earth
|
|
|
|
|
You take a string, encode it using one encoding and decode it using another, and you wonder why it's not working?
You have to decode the data using the same encoding as it was encoded with.
---
Year happy = new Year(2007);
|
|
|
|
|
How can I used VBSkinner in C#.Net.
tell me details of that.
|
|
|
|
|
1 - please use meaningful titles
2 - what is VBSkinner ?
If it's a VB.NET dll, you can just import and use it. If it's VB6, you can't use it unless it exposes itself via COM.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
HI ALL
PROBLEM DESCRIPTION:
I AM OPEN WINDOW (DIALOGE BOX) USING JAVASCRIPT, PROMPT TO USER TO ANSWER QUESTION THEN ACCORDING TO ANSWERS I WANT CALL C# FUNCTION FROM CLIEN-SIDE.
HOW CAN I DO THAT PLEASE.
ALA QUNAIBI
ALA QUNAIBI
|
|
|
|
|
Please don't write in all capitals. On the web that is considered the equivalent of screaming.
What you are asking for is not possible. You can not call a server method from client code.
What you can do is to send a request to the server, and make the server code that handles the request call the C# method you want to call.
You can use AJAX to do the request to the server without having to reload the current web page.
---
Year happy = new Year(2007);
|
|
|
|