|
|
Umm, it will be caught up in an installer once it's all working, however now I would like a method of finding out about the drivers with out having to run an installer (I can see a use for it not connected to this project!)
Glenn
|
|
|
|
|
Thanks for that still learning the correct (CP) way of doing things.
Glenn
|
|
|
|
|
Hi All
I've got some problems with converting readed text from *.doc file. I'm using this code:
FileStream fs = null;
fs = new FileStream(plik.ToString(), FileMode.Open);
byte[] example = new byte[fs.Length];
fs.Read(example, 0, example.Length);
string outtext = "";
int count = 0;
for (int i = 2560; i < example.Length; i++)
{
if (example[i] == 0)
{
break;
}
count++;
}
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding(1250));
br.BaseStream.Position = 2560;
byte[] newarr = br.ReadBytes(count);
outtext = System.Text.UTF8Encoding.UTF8.GetString(newarr);
string str = "";
for (int i = 0; i < outtext.Length; i++)
{
if ((outtext[i] >= '!' && outtext[i] <= '~') || (outtext[i] == ' ') || (outtext[i] == '\r'))
{
str += outtext[i];
}
}
fs.Close();
tekst = str;
It works great till I try to read file with polish symbols (ISO-8859-2). I try'ed to convert it to ISO-8859-2 but it is not working propertly.
Could anybody help me with this problem?
|
|
|
|
|
"Windows-1250 is similar to ISO-8859-2 and has all the printable characters it has and more. However a few of them are rearranged (unlike Windows-1252, which keeps all printable characters from ISO-8859-1 in the same place). Most of the rearrangements seem to have been done to keep characters shared with Windows-1252 in the same place as in Windows-1252 but three of the characters moved (Ą,Ľ,ź) cannot be explained this way."
I'd suggest you use "ISO-8859-2" as your encoding to read the file, not Windows-1250.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
Satay84 wrote: I'm using ISO-8859-2 encription:
Not in the code you posted;
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding(1250));
If you read them in the correct format and save them as UTF8, you should not see a loss of information.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
As You told me I convert sorce data to iso-8859-2 and then to UTF-8, but the result was the same. If I convert english docs it works perfect, but when I use polish docs i get this result string: "."
There's solution that I create for this:
FileStream fs = null;
try
{
fs = new FileStream(plik.ToString(), FileMode.Open);
byte[] example = new byte[fs.Length];
fs.Read(example, 0, example.Length);
string outtext = "";
int count = 0;
for (int i = 2560; i < example.Length; i++)
{
if (example[i] == 0)
{
break;
}
count++;
}
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding("iso-8859-2"));
br.BaseStream.Position = 2560;
byte[] newarr = br.ReadBytes(count);
outtext = System.Text.UTF8Encoding.UTF8.GetString(newarr);
string str = "";
for (int i = 0; i < outtext.Length; i++)
{
if ((outtext[i] >= '!' && outtext[i] <= '~') || (outtext[i] == ' ') || (outtext[i] == '\r'))
{
str += outtext[i];
}
}
fs.Close();
tekst = str;
}
catch (Exception exc)
{
Console.WriteLine(exc.ToString());
return;
}
So could anybody give me any other advice?
|
|
|
|
|
Aight, let's take a look at this piece of the code;
BinaryReader br = new BinaryReader(fs, Encoding.GetEncoding("iso-8859-2"));
br.BaseStream.Position = 2560;
byte[] newarr = br.ReadBytes(count);
outtext = System.Text.UTF8Encoding.UTF8.GetString(newarr);
You are reading the file as an array of bytes - those values won't change based on the encoding. Once you convert it to a string, it'll have to know what encoding to use to convert those bytes into the correct character. That's what your last line is doing, but it is using the UTF8-encoding - not your iso-8859-2. Hence, the system will interpret those bytes that you just read as UTF8.
Read them as the iso-format, and all should work.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I used:
outtext = Encoding.GetEncoding("iso-8859-2").GetString(newarr);
but it's not working. Where should I use this encription?
|
|
|
|
|
It's not an encryption, but an encoding. Below example should work, tested it with the Polish Army Oath from the Wikipedia;
public static void Main (string[] args)
{
Encoding enc = Encoding.GetEncoding("iso-8859-2");
string someString = File.ReadAllText("test.txt", enc);
Console.WriteLine (someString);
}
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks, but I know this type of encoding. I just don't know how to use it with binaryreader that I need to use.
|
|
|
|
|
Why do you "need" to read it as binary and convert it to string, when you can read it as a string?
There's an example[^] on MSDN that shows how to use the encoding with a array of bytes.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hello
I need to have a ressource folder automaticaly created into the bin folder by the compiler and automaticaly copy a text file in it
Purpose :
My application need to read some information into a predefined textfile
I can obviously create that text file into the ressouce folder of the project
But when I compile the project I need that this text file will be automaticaly copied into the ressouce folder in the Bin Folder
What is the method to do that ?
Thanks a lot for your help
|
|
|
|
|
baranils wrote: What is the method to do that ?
You could include the file and go to the properties page and select "Always copy", or create a batch-file and execute that prior to build. Remember that the IDE can execute commands before build, is somewhere in the projects' settings.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Thank You !
"Always copy" is the tip !!
|
|
|
|
|
in some IDE's (such as Visual Studio) you can specify pre-build and post-build commands; these get executed at the start and termination of a build, and use a DOS-like syntax. Copying some files in this way is a typical usage.
OTOH if your files are present while building, what makes you think they will disappear? You can add all kinds of files to a project, and get them deployed. Again, VS gives you a choice of actions to be taken for files it doesn't normally know about, the choices are: none, compile, content, embedded resource. I suggest you experiment a little.
|
|
|
|
|
I'm developing a c# desktop application that manage Facebook ads ( create , send , delete ...).
I cant find a way to manipulate Facebook api related to ads .
I will be grateful for your help .
thanks .
|
|
|
|
|
twotwins wrote: I cant find a way to manipulate Facebook api related to ads .
Luckily, Facebook provides documentation[^].
Enjoy the read
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
there are nothing there useful I'm searching how to manipulate the fb ads api with c# and thanks for trying to help me .
|
|
|
|
|
twotwins wrote: there are nothing there useful
It descibes how to use the FB ads api.
twotwins wrote: I'm searching how to manipulate the fb ads api with c#
The documentation is language-agnostic. If you need a third-party wrapper that talks from C# to FB on your behalf, have a look at the Facebook SDK[^].
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
|
Hi Everyone,
I want to create an Application for Image Cup. In Which the requirement is that we can change the Image Cover from application.
So Please help me where from i can start.
Thanks
If you can think then I Can.
|
|
|
|
|
What is an image cup and what is an image cover? The question needs a lot more definition.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You already asked this question yesterday in QA.
Asking it again is not going to change the questions, nor the answers you get. You simply haven't provided enough detail about EXACTLY what you are doing and how you are doing it for anyone to help with any accuracy.
|
|
|
|