|
You can't read a binary file as text. Read it as bytes instead.
---
b { font-weight: normal; }
|
|
|
|
|
To read a binary as an array of bytes (with a lot of help from turbochimp):
using System.IO;
byte[] buffer = null;
Stream file = new FileStream(@"C:\myfile.bin", FileMode.Open, FileAccess.Read);
buffer = new byte[file.Length];
file.Read(buffer, 0, (int)file.Length);
file.Close();
Now, all the file contents are in "buffer" and you can work with it.
Hope it helps you.
|
|
|
|
|
Where i can find any information about creating a vector drawing software, about technical, and algorithm?. Thank you very much
Nothing
|
|
|
|
|
|
I think it hard to catch the events of line, rectangle,... Do you know any project about it?
Nothing
-- modified at 19:52 Thursday 29th September, 2005
|
|
|
|
|
Hi All,
I'm totally stymied trying to deserialize an xml document to an object that I created in a dynamic assembly:
exception:
"Unable to generate a serializer for type Person from assembly <unknown> because the assembly may be dynamic. Save the assembly and load it from disk to use it with XmlSerialization."
Before I post a pile of code, I hoped someone might have an insight to this problem. I have tried saving the assembly to disk, then reloading it using System.AppDomain.Load(byte[] rawAssembly,byte[] rawSymbolStore) from reading the dynamic dll and pdb from disk...
Everything works (the assembly is loaded and the types I defined dynamically can be reflected) until I get to the point of declaring the xml serializer for my type...
Arg. Help.
Rein
|
|
|
|
|
|
There is hope
Alas, loading a string AssemblyName raises this exception:
"The located assembly's manifest definition with name 'DynMod' does not match the assembly reference."
What do you suppose I am missing?
Rein
|
|
|
|
|
ooops,
disregard that... was using a different name for the assembly than the module. They're the same name now and the error is gone.
Thanks again,
Rein
|
|
|
|
|
typical story, new to c# and got a, probably stupid, question!
I am trying to compile the code at http://www.codeproject.com/dotnet/pinvokeaddshare.asp
Its intended to create a file share.
When I run the code it throws a System.Security.SecurityException.
I put the responcible line in a try | catch block, just in case it was a problem with the code and checked exceptions.
I examined the code and the return from the method called in the erroring line returns a status code which says that the share was created but it was not.
I am an admin of the locel machine, which is where I am creating the share.
What I am thinking now is that Visual Studio executes code in a sandbox kind of arrangement and a security level has to be specified for executing code!!! does this feature exsits?
Any ideas?
Thanks
|
|
|
|
|
|
typical story, new to c# and got a, probably stupid, question!
I am trying to compile the code at http://www.codeproject.com/dotnet/pinvokeaddshare.asp
Its intended to create a file share.
When I run the code it throws a System.Security.SecurityException.
I put the responcible line in a try | catch block, just in case it was a problem with the code and checked exceptions.
I examined the code and the return from the method called in the erroring line returns a status code which says that the share was created but it was not.
I am an admin of the locel machine, which is where I am creating the share.
What I am thinking now is that Visual Studio executes code in a sandbox kind of arrangement and a security level has to be specified for executing code!!! does this feature exsits?
Any ideas!
|
|
|
|
|
Hi
if I read command line args I get results of @"line\nline2"
how can I convert this into "line1\nline2"?
In other words: how to remove the '@'?
Ariadne
|
|
|
|
|
|
leppie wrote:
They are the same thing, the @ only defines different escaping routines.
ok, but how can I change the escaping routine.
if I do: sPrompt=args[i] and args[i] contains a '\' the real string of sPrompt is something like: @"...\...", but I want show this prompt in MessagBox without this '@' escape function. ie. I want show more than one line, if I get in args[i] a '\n'
thanks!
Ariadne
|
|
|
|
|
|
The escaping routine is for the compiler, and not for the string itself.
If you do Console.WriteLine("line1\\nline2") or Console.WriteLine(@"line1\nline2") , you'll get the same output:
line1\nline2 In the first case, to insert a backslash in the string, you need to double it (otherwise it will be interpreted as a special character: eg. \n as newline). In the second example, the @ means that a different escaping will be performed (most special characters won't be escaped) so \n produces exactly that, \n .
The @ makes a difference when specifying paths in code:
string path1 = "C:\\Program Files\\Microsoft";
string path2 = @"C:\Program Files\Microsoft"; In memory, both path1 and path2 will contain exactly the same.
If you read the string from anywhere typed by the user, you don't have to worry about escape characters. If he types one backslash, you'll get it. Escaping is only when specifying strings in code.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Luis Alonso Ramos wrote:
The escaping routine is for the compiler, and not for the string itself.
no, I think not, because I get the '@'-problem at runtime.
but I'm happy leppie solved the problem with
sPrompt=sPrompt.Replace(@"\n","\n");
It works!
Thanks leppie
Ariadne
|
|
|
|
|
What that particular line of code is doing is replacing the characters \n (backslash followed by an n ) with an actual newline character. It is the exact equivalent of: sPrompt = sPrompt.Replace("\\n", "\n") .
Somehow you read the sPrompt string from somewhere that doesn't support escaping of characters (a resource maybe?) so you ended up with the characters '\' and 'n' in memory, instead of the actual newline (char 13) character.
But the escaping only works when specifying strings by code, and it's performed by the compiler.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
I have a .net windows client application that queries a .net web service. After the client has called the web service if netstat is run from the command line the results will show 10 sockets still open. Below is the code from my client app. My questions are
1. Why does the client app need 10 sockets?
2. What can I do to force the closing of the sockets since the GC.Collect() & GC.WaitForPendingFinalizers() methods don't seem to be doing it?
3. Does it really matter if the sockets are not immediately closed?
Private Sub LogIn()<br />
If IsUserOffLine() Then Exit Sub<br />
Dim wsEmpInfo As EmpInfoWS.EmployeeInformation = BF.SetUpWS()<br />
Try<br />
wsEmpInfo.SetEmployeeCheckIn(BF.GetUserName, txtLogInComments.Text)<br />
Catch Ex As Exception<br />
Call IsUserOffLine()<br />
Finally<br />
wsEmpInfo.Dispose()<br />
End Try<br />
Dim tRefreshForm As New Thread(New ThreadStart(AddressOf RefreshForm))<br />
Try<br />
tRefreshForm.Start()<br />
Catch ex As Exception<br />
tRefreshForm = Nothing<br />
End Try<br />
End Sub<br />
<br />
Private Sub RefreshForm()<br />
Try<br />
Call PopulateForm()<br />
Call HandleNotify()<br />
Call ShowScrollingNote()<br />
Call CleanUp()<br />
Catch<br />
End Try<br />
End Sub<br />
<br />
Private Sub CleanUp()<br />
Try<br />
GC.Collect()<br />
GC.WaitForPendingFinalizers()<br />
Catch<br />
End Try<br />
End Sub
I appreciate any suggesting you have, thank you.
Jason W.
|
|
|
|
|
It would be very useful to provide the code where you actually call the web service.
www.troschuetz.de
|
|
|
|
|
Not sure if this helps but it's worth a try.
<br />
Public Function SetUpWS() As EmpInfoWS.EmployeeInformation<br />
Dim wsEmpInfo As New EmpInfoWS.EmployeeInformation<br />
wsEmpInfo.Url = GetEmpInfoWSURL()<br />
wsEmpInfo.Credentials = System.Net.CredentialCache.DefaultCredentials<br />
Return wsEmpInfo<br />
End Function<br />
Jason W.
|
|
|
|
|
|
Here is what netstat is showing.
<br />
TCP COMPUTERNAME:4483 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4484 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4485 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4486 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4487 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4488 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4489 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4490 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4491 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4492 111.111.111.111:https TIME_WAIT<br />
Jason W.
|
|
|
|
|
|