|
Depends on the file type. For a description of file types you might check this link.
Basically you craete a BinaryReader . You can then read the complete header with ReadBytes(count) and convert them yourself, or you can read them information by information, like ReadInt , ReadBoolean etc.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
u can try
System.IO.FileInfo fl = new System.IO.FileInfo("full path of file");
and from this fl object u can check name, version, creation date, modified date etc of that file
rahul
|
|
|
|
|
I have a string, which i'm retrieving from the database, and i need to identify whether the string is unicode or not.
Either by string, or by enumerating the charachters and identifying if they are unicode.
I've had no luck in my own searches. (.net 1.1)
Cheers
Tris
-- modified at 7:14 Wednesday 7th June, 2006
|
|
|
|
|
Here is the implementation for you:
bool IsCharUnicode(char c)
{
return true;
}
Any string is Unicode in C#. The database access layer must transform the string to or from Unicode (except any decent database would use Unicode anyway) - it is not your problem.
If it fails, then it is broken. If you have to live with a broken access layer you might use the encoding classes to go from the broken string representation back to bytes, and then another encoding to get the correct string. This will only work if the database access layer converts it using an encoding where every byte sequence can be matched to a single string (for example codepage 1252). Yes, I know this is not clearly written, but it will have to do.
|
|
|
|
|
I have to work an output into a system that was built on UTF-7 strings / files, but now requires a degree of Unicode support. So all Unicode strings need to be converted to HEX and stored in a specialy flagged field.
Unfortunately, i can't encode normal strings, as this will interfear with the legacy data.
I really need a way of determinging if a charachter is exclusively available in Unicode.
Hope that clears things up. :/
Cheers
Tris
|
|
|
|
|
UTF-7 strings ARE unicode strings. More specifically it is a 7 bit encoding of the Unicode character set - just like UTF-8, UTF-16 and UTF-32 are 8, 16, and 32 bit encodings.
If you have read a string as if it was ASCII, but it actually contains UTF-7, convert as follows (from memory, so expect typos etc):
Encoding.UTF7.GetString(Encoding.ASCII.GetBytes(theString))
To generate a UTF7 encoded string that will turn out correct when set as an ASCII text do this:
Encoding.ASCII.GetString(Encoding.UTF7.GetBytes(theString))
If the result of the conversion is the same as what you started with - then it does not require any conversion, so a simple string comparison will be enough to tell you, but you really do not need this if you already have UTF7, just convert everything.
Also notice that besides maybe Klingon and the likes, you should expect every character to be available though at least ONE codepage besides Unicode. You need to think about it as "does this codepage support this character", not as "Does this character require Unicode", as the latter simply does not have a defined result.
|
|
|
|
|
This is purely for the back end.
It's required to send Indian, Chinese, Japanese, Arabic, Hebrew etc, all through the same data stream. Fun Fun
You have me on the right track now tho, cheers.
Tris
|
|
|
|
|
Hi.
Im running a private live communications server and I would now like to add windows messenger-like functionality to an application which will use this server to communicate.
Whats the best way of doing this?
Can you integrate the windows messenger client directly in some way (preferably with full control) or do you have to create your own client? If so, which api is best to use, the RTC api or some messenger api?
regards
/Rickard
|
|
|
|
|
Anyone got any good ideas?
|
|
|
|
|
Hello!
My problem is the following, I have to make a program that automaticaly finds a folder in a 3rd party program's FolderBrowseDialog. It deals with TreeView. The only thing I can get is the SysTreeView32 Handle.
For instance: I have the path "C:\Windows\System32\" and the 3rd party program need to find this folder from File->Import.
I have found about SHBrowseForFolder and BrowseCallbackProc, but both deals with the main program and you know the proccess.
I believe my only way out is PostMessage and SendMessage.
Does anyone have any idea??
Thanks
|
|
|
|
|
HI,
I have the following scenario.
I am getting data from a web service which is encrypted. I decrypt the data and get a buffer of bytes. Now i need to convert that to a string. When i use
Encoding.UTF8.GetString(byte[]), the returned string is complete but there is a space between every two consecutive characters. But when i use
Encoding.Unicode.GetString(byte[])
then the string is fine(without spaces), but it eats away the last character of the string.
Here is the code
byte[] cipherTextBytes=Convert.FromBase64String(cipherText);
/*
My decryption code goes here
*/
return Encoding.UTF8.GetString(removeLength
(outputBuffer));
Any solution please....
Wasif Ehsan
|
|
|
|
|
I am using GDI+ for debugging my game, most ( but not all.. ) of the drawing code will replaced by DirectX calls, but my textures still need to be creaded, and GDI is to slow:
I have a application now:
http://129.125.101.130/~marijn/images/image0002.jpg[^]
And First you need to click on the tileset viewer, and second you need to click on a location in the leveleditor.. But with every click you need to wait a couple of seconds.. sometime one, sometime more, but it just takes to long.
On every click a huge bitmap get generated and the engine will draw that bitmap ( 100*32, 64*32 huge ). Now thinking about it.. I will make some time test what is taking so long...
But now my qeustion: Are ther FASTER ways to draw ? ( with use of a other library like GDI+.. )
|
|
|
|
|
hi
i have a usercontrol named CtlSimpleHtml , one module in it changes its properties.
but don't work??!! i check it , these properties value changes according to coding , but these changed didn't show!!!
my code:
<br />
public void load_html()<br />
{<br />
pnl_viewer.Visible=false;
pnl_Story.Visible=false;
pnl_AuthorName.Visible=true;
pnl_AuthorName.Location=new Point(8,8);
pnl_AuthorName.Size =new Size(624,392);<br />
pnl_AuthorName.Update();<br />
pnl_Story.Update();<br />
pnl_viewer.Update();<br />
}<br />
thanks
-- modified at 5:30 Wednesday 7th June, 2006
|
|
|
|
|
nafiseh_salmani wrote: pnl_viewer.Visible=false; //a panel on the usercontrol
pnl_Story.Visible=false;//a panel on the usercontrol
pnl_AuthorName.Visible=true;//a panel on the usercontrol
Use Hide and Show methods instead of Visible.
control.Hide();
control.Show();
Best Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
thanks, but it dosen't work also!!!
<br />
public void load_html()<br />
{<br />
<br />
pnl_viewer.Hide();<br />
pnl_Story.Hide();<br />
pnl_AuthorName.Show();<br />
pnl_AuthorName.Location=new Point(8,8);<br />
pnl_viewer.Location=new Point(8,672);<br />
pnl_AuthorName.Update();<br />
pnl_Story.Update();<br />
pnl_viewer.Update();<br />
}
|
|
|
|
|
nafiseh_salmani wrote: pnl_viewer.Hide();pnl_viewer.Location=new Point(8,672);
Why you are setting its location after hiding it? Well! i checked it with the same location value and after showing the panel with show() method, obviously, it was not in front of my eyes because of its y's value that is 672.
I checked it again, and here is the tested code.
private void button1_Click(object sender, EventArgs e)
{
/* panel1.Hide();
panel1.Location = new Point(8,333);
//////both are working in my form.
*/
this.unload();
}
public void unload()
{
this.panel1.Hide();
}
private void button2_Click(object sender, EventArgs e)
{
this.panel1.Show();
this.textBox1.Text = "hello";
}
try to check your code regarding panels.
Best Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
Hi,
I want to make a control invisible during handle creation but it doesn't work,eventhough i check the visible property and it is false.
What should i do?
|
|
|
|
|
UAU wrote: I want to make a control invisible
Use
Control.Hide();
Best Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
Dear all,
Finally i found some solution to encrypt XML file. instead of encrypting the whole file iam encrypting the Outer XML string alone and writing string again into the file.
Here iam calculating the CRC for the bytes and iam appending it to end of XML as a separate tag. so whenever i load the XML i will calcualte CRC and compare it with tag value If both are same then the XML file is not corrupted else the file is corrupted. here i have an issue, suppose the user changed the tag. then the XML document throws the error that unformatted document. so i can't check value of CRC since i can't read the CRC value from XML. Can anyone please pointout some other idea here.
Thanks and Regards
Srini
|
|
|
|
|
I am working on an application with a rich text box and I am starting to go crazy.
Here’s what I need to do:
* Set the width of the text box to the width of the widest string.
* Get the height of the text box given a particular width so that all text fits in and there are no vertical or horizontal gaps (i.e. tightest configuration) and no scroll bars.
* Get the next narrowest/widest configuration of the text box which has one less or one more line.
I have tried using MeasureString (with GenericTypographic and GenericDefault), I have tried using SetMeasureableCharactersRanges, I have tried counting pixels, I have tried enabling anti-aliasing and smoothing text, I feel that I have tried everything.
Unfortunately it seems that when I measure strings and then use these measurements with the text box, they mismatch.
For example, my text measuring function tells me that the width of the longest word is 10. However, when I set the width of the text box to 10 it turns out to be too small.
To make it right I have to add a fudge factor. Unfortunately it seems that for different strings the amount that I need to add varies. Sometimes it can be 1, sometimes it can be 10.
I am aware of the issues between GDI and GDI+ but is there nothing one can do?
Any help/suggestions would be greatly appreciated.
Thanks.
|
|
|
|
|
tech_01 wrote: To make it right I have to add a fudge factor. Unfortunately it seems that for different strings the amount that I need to add varies. Sometimes it can be 1, sometimes it can be 10.
Have you tried to calculate the Average space required by each character in the text box?
if this idea works then please! let me to know.
Thanks and
Best Regards.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
Hi All
I need to use TripleDES encyption for my Web Application. I want to store the key used for encryption in the web.config file. How would I go about choosing a key, storing the key in the web.config, retrieving the key for encryption and decryption, and then doing the encryption itself. I'm relatively new at doing cryptography in C#.
Thanks
-- modified at 2:46 Wednesday 7th June, 2006
|
|
|
|
|
You can see the sample from microsoft in your visual studio directory.
C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\QuickStart\howto\samples\cryptography\fileencrypt\cs
|
|
|
|
|
I don't want to read data in from a file, then encrypt and decrypt it. I want to retrieve a value from the HTTP HEADERS and encrypt that, then redirect from that page with the ecrypted value appended to the URL and decrypt it on another page.
|
|
|
|
|
Hi,
You can use the following code.
TripleDESCryptoServiceProvider provider = null;
MemoryStream ms= null;
CryptoStream cs = null;
StreamWriter sw = null;
try
{
provider = new TripleDESCryptoServiceProvider();
ms = new MemoryStream();
cs = new CryptoStream(ms,provider.CreateEncryptor(Key,Vector),CryptoStreamMode.Write);
sw = new StreamWriter(cs);
sw.Write(strValue);
sw.Flush();
cs.FlushFinalBlock();
ms.Flush();
}
catch(Exception)
{
//do exception handling
}
finally
{
sw.Close();
cs.Close();
ms.Close();
}
Guess this will help you.
Regards,
Mahen
|
|
|
|