|
|
is it possible to update twitter status from my C# application using textbox?
|
|
|
|
|
Absolutely, since Twitter has an interface built in to everything. In fact, if you write text on a paper tablet it will update your Twitter account also, magically, with no coding at all.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I'm pretty sure it's even built into tiolet paper judging by some of the posts.
Don't blame me. I voted for Chuck Norris.
|
|
|
|
|
Try googling before asking next time. For a question like this, I'd suggest the terms 'Twitter API'. This is the first result.
http://apiwiki.twitter.com/[^]
|
|
|
|
|
...I'm hoping that this is a stupid question:
I'm needing to pull a CLOB field off of an Oracle table. It just so happens that the character string that was input into that CLOB field conforms to an XML Schema, with a few character replacement tweaks that I have to scrub. less than signs have been replaced with amp lt; and greater than signs have been replaced with amp gt;
I mention that because it throws a significant wrinkle into the processing that I have to do. I have to pull a CLOB out of a DataReader's stream, scrub the string, and then dump the string back into a (MemoryStream???) to pass into the XML DOM objects. I have no idea if this is even close to what I need to be doing, as I have very little experience working directly with Streams in this way.
Can someone tell me how they would go about pulling the string data out of the DataReader stream and passing it into an XMLTextReader as a separate stream for parsing?
Am I even on the right path?
"I need build Skynet. Plz send code"
|
|
|
|
|
hi, I create a table with the below code. Everything is okay but I can not set the "identity specification" property to yes.
This is okay without identity parameter
SqlCommand cmd = new SqlCommand(@"Create table ItemStock (Itemno tinyint, Urun nchar(20),Fiyat float, primary key(Itemno))", baglan);
This is not okay with identity parameter
SqlCommand cmd = new SqlCommand(@"Create table ItemStock (Itemno tinyint, Urun nchar(20),Fiyat float, primary key(Itemno), Set Identity_insert(Itemno) on", baglan);
|
|
|
|
|
try somewthing like this:
SqlCommand cmd = new SqlCommand(@"Create table ItemStock (Itemno tinyint IDENTITY(1,1) Primary Key Clustered,
Urun nchar(20),Fiyat float)", baglan);
If it still doesn't work try replacing the type from tinyint to int.
the (1,1) after IDENTITY represents the identity seed(start) and the increment.
|
|
|
|
|
worked fine with tinyint, thank you very much! By the way, I used Primary key(columnname) but you mentioned Primary key Clustured. what is the difference?
|
|
|
|
|
A clustered index will store the records in approximately the order of the index. That can be useful if you read a range of records because they can all be read from the hard drive without performing extra seeks. Since the data can only be ordered one way, you can only have one clustered index on each table. Typically, the primary key is chosen as the clustered index, unless you have a good reason to choose another one.
|
|
|
|
|
|
I'm trying to pass a variable from a GridViewRowEvent method to a DataListItemEvent method in a C# program.
I have the following:
public void My_RowDataBound2(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int lblAmount = (int)DataBinder.Eval(e.Row.DataItem, "Amount");
totalAmount += lblAmount;
x += 1;
}
else
{
CountNumberRows(x);
}
}
public int CountNumberRows(int x) { return x; }
public void My_ItemDataBound(object sender, DataListItemEventArgs e) {
if (e.Item.DataItem != null)
{
Label dummyVariable = (Label)e.Item.FindControl("abc");
abc.Text = CountNumberRows(x).ToString();
}
}
Then in my ASP.NET file I have the following entry:
DataList
...
Gridview
...
Gridview
...
<asp:Label ID="abc" runat="server"></asp>
...
DataList
And I get just "0" for the "abc" value in my file. I know the GridViewEvent method works because the variable
totalAmount correctly sums up all the data each time it is called by My_RowDataBound2, and inserted into the appropriate place in the GridView on my ASP.NET Page. But "abc" just shows 0. abc is just supposed to show the number of rows contained in the GridView.
Basically, I just need to get the "x" value from
My_RowDataBound2 method, pass it to the
My_ItemDataBound event which then passes it as a label to the ASP.NET Page. But the label is just showing "0"
If I take:
public int CountNumberRows(int x) { return x; } and change it to:
public int CountNumberRows(int x) { x= "123"; return x; } , it passes the "123" to the abc label. But I don't know how to pass the x calculation out of the GridView to the DataList. Any suggestions? I appreciate your help
|
|
|
|
|
Dear all,
How can i get the names of the directories of a ftp server in c#?
Thanks.
|
|
|
|
|
FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + server + "/"));
ftp.Method = WebRequestMethods.Ftp.ListDirectory;
WebResponse response = ftp.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi Mark,
Thank you for reply, but with this code you will get the file names.
What i need is the folder names.
|
|
|
|
|
You have what you need to research for yourself
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
In C# app i need to check if a file is a text file or is a binary file,
how can i do this ?
i can't check by file extension, because isn't meaningful for me .
|
|
|
|
|
|
i've found a solutions, if can be useful for someone else :
static bool IsTextFile(string fileName)
{
byte[] file;
using (System.IO.FileStream stream = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
file = new byte[stream.Length];
stream.Read(file, 0, file.Length);
}
if (file.Length > 3 && ((file[0] == 0x00 && file[1] == 0x00 && file[2] == 0xFE && file[2] == 0xFF /*UCS-4*/)))
return true;
else if (file.Length > 2 && ((file[0] == 0xEF && file[1] == 0xBB && file[2] == 0xBF /*UTF-8*/)))
return true;
else if (file.Length > 1 && ((file[0] == 0xFF && file[1] == 0xFE /*Unicode*/)))
return true;
else if (file.Length > 1 && (file[0] == 0xFE && file[1] == 0xFF /*Unicode Big Endian*/))
return true;
else
{
for (int i = 0; i < file.Length; i++)
if (file[i] > 0x80)
return false;
return true;
}
}
Bye
|
|
|
|
|
Well you know, that is really not correct - or rather, too simplistic. UTF-8 doesn't require a byte order mark, for starters, and non-text can very easily start with an accidental byte order mark (since it is so short), you should really write a more complex test. I'll see what I can come up with, I may get back to you.
Edit: how about this?
static bool IsText(byte[] data)
{
if (data.Length < 16)
throw new Exception("Data is too short to guess the encoding");
byte asciitester = 0;
for (int i = 0; i < data.Length; i++)
asciitester |= data[i];
if (asciitester < 0x80)
return true;
if (IsValidUTF8(data))
return true;
if (IsValidUTF16(data))
return true;
return false;
}
static bool IsValidUTF16(byte[] data)
{
if ((data.Length & 1) == 1)
return false;
bool LittleEndian;
ushort BOM = BitConverter.ToUInt16(data, 0);
if (BOM == 0xFFFE)
LittleEndian = false;
else if (BOM == 0xFEFF)
LittleEndian = true;
else
return false;
bool SecondOfSurrogatePair = false;
for (int i = 2; i < data.Length; i+=2)
{
int code;
if (LittleEndian)
code = data[i] | (data[i + 1] << 8);
else
code = (data[i] << 8) | data[i + 1];
if (SecondOfSurrogatePair)
{
if (code < 0xDC00 || code > 0xDFFF)
return false;
SecondOfSurrogatePair = false;
}
else
{
if (code >= 0xD800 && code <= 0xDBFF)
SecondOfSurrogatePair = true;
}
}
return SecondOfSurrogatePair;
}
static bool IsValidUTF8(byte[] data)
{
int index = 0;
if (data[0] == 0xEF)
{
if (data[1] != 0xBB ||
data[2] != 0xBF)
return false;
index = 3;
}
int mode = 0;
for (int i = index; i < data.Length; i++)
{
switch (mode)
{
case 0:
if (data[i] < 0x80)
break;
else if (data[i] < 0xC0)
return false;
else if (data[i] < 0xE0)
mode = 1;
else if (data[i] < 0xF0)
mode = 2;
else if (data[i] < 0xF5)
mode = 3;
else
return false;
break;
case 1:
case 2:
case 3:
if (data[i] < 0x80 || data[i] >= 0xC0)
return false;
mode--;
break;
default:
return false;
}
}
return mode == 0;
}
I suppose you could tests to see if there are any unprintable characters, too.
modified on Monday, April 5, 2010 2:02 PM
|
|
|
|
|
Btw, could I get some feedback on code this, please? Specifically on whether the result is correct as far as it tests, this test is "supposed to" be very optimistic in what it accepts as text, so I'm especially interested in whether there are valid UTF-16 or UTF-8 strings that get rejected by the test. I'm not exactly a Unicode expert..
|
|
|
|
|
This isn't going to work in all cases since there is no requirement for a text file to have byte order marks. Also, what if the binary file just happens to have those very bytes in the place where you would normally have byte order marks?
What do you do if there are NO byte order marks (which is most text files anyway...)?
|
|
|
|
|
Hey, what happened to DOS/Windows marking the End Of File with Ctrl+Z (26) when it's a text file?
|
|
|
|
|
That character never made it into the text file. I only ever saw it used when copying from CON to a file. Ctrl-Z just denoted the end of the stream that was being typed.
|
|
|
|
|
Text mode reading wouldn't return it, but I used to see it when reading text files in binary mode.
|
|
|
|