Click here to Skip to main content
15,890,438 members
Home / Discussions / C#
   

C#

 
QuestionPass variable from GridViewRowEvent method to DataListItemEvent method in C# using ASP.NET Pin
chris.hagelstein5-Apr-10 6:43
chris.hagelstein5-Apr-10 6:43 
Questionftp server folders Pin
Priya Prk5-Apr-10 6:23
Priya Prk5-Apr-10 6:23 
AnswerRe: ftp server folders Pin
Not Active5-Apr-10 6:47
mentorNot Active5-Apr-10 6:47 
GeneralRe: ftp server folders Pin
Priya Prk5-Apr-10 21:16
Priya Prk5-Apr-10 21:16 
GeneralRe: ftp server folders Pin
Not Active6-Apr-10 2:47
mentorNot Active6-Apr-10 2:47 
Questionget the file type of a file Pin
aleroot5-Apr-10 4:32
aleroot5-Apr-10 4:32 
AnswerRe: get the file type of a file [modified] Pin
PIEBALDconsult5-Apr-10 4:53
mvePIEBALDconsult5-Apr-10 4:53 
GeneralRe: get the file type of a file Pin
aleroot5-Apr-10 7:15
aleroot5-Apr-10 7:15 
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
GeneralRe: get the file type of a file [modified] Pin
harold aptroot5-Apr-10 7:19
harold aptroot5-Apr-10 7:19 
GeneralRe: get the file type of a file Pin
harold aptroot5-Apr-10 12:45
harold aptroot5-Apr-10 12:45 
GeneralRe: get the file type of a file Pin
Dave Kreskowiak5-Apr-10 7:54
mveDave Kreskowiak5-Apr-10 7:54 
GeneralRe: get the file type of a file Pin
PIEBALDconsult5-Apr-10 8:48
mvePIEBALDconsult5-Apr-10 8:48 
GeneralRe: get the file type of a file Pin
Dave Kreskowiak5-Apr-10 10:19
mveDave Kreskowiak5-Apr-10 10:19 
GeneralRe: get the file type of a file Pin
PIEBALDconsult5-Apr-10 12:02
mvePIEBALDconsult5-Apr-10 12:02 
AnswerRe: get the file type of a file Pin
harold aptroot5-Apr-10 5:11
harold aptroot5-Apr-10 5:11 
GeneralRe: get the file type of a file Pin
PIEBALDconsult5-Apr-10 9:29
mvePIEBALDconsult5-Apr-10 9:29 
GeneralRe: get the file type of a file Pin
harold aptroot5-Apr-10 12:35
harold aptroot5-Apr-10 12:35 
AnswerRe: get the file type of a file Pin
AspDotNetDev5-Apr-10 11:40
protectorAspDotNetDev5-Apr-10 11:40 
QuestionIs there any lnk parser in C#? Pin
newcoder19995-Apr-10 4:07
newcoder19995-Apr-10 4:07 
QuestionWhite Flicker When Observing an Application Using Double Buffer Over RDP Pin
Catfish5405-Apr-10 3:33
Catfish5405-Apr-10 3:33 
QuestionFileSystemWatcher HELP PLEASE !! Pin
Rikq4-Apr-10 21:21
Rikq4-Apr-10 21:21 
AnswerRe: FileSystemWatcher HELP PLEASE !! Pin
OriginalGriff4-Apr-10 21:54
mveOriginalGriff4-Apr-10 21:54 
AnswerRe: FileSystemWatcher HELP PLEASE !! Pin
FyreWyrm5-Apr-10 16:12
FyreWyrm5-Apr-10 16:12 
QuestionHow to send Email in C# through the Exchange Server? Pin
ravis194-Apr-10 21:00
ravis194-Apr-10 21:00 
AnswerRe: How to send Email in C# through the Exchange Server? Pin
Abhinav S4-Apr-10 21:49
Abhinav S4-Apr-10 21:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.