|
Thanks. I had read this, but for some reason I cannot now remember, I questioned it. Seems pretty straightforward now!
|
|
|
|
|
You're welcome.
Mika
P.s. Really glad to hear that you thought about this instead if just asking
|
|
|
|
|
I think what I blew off was that SPEFICICALLY, enumeration wasn't thread safe. In my mind I thought "well, if getting things from a synchronized queue isn't thread safe, what's the point?"
My brain didn't translate the part where "Only the enumeration itself needs LOCK, the rest of the Queue methods do not."
|
|
|
|
|
Hi, everyone...
I have a stream and put in a GZipStream, save in SQL 2005, after that I load this stream from sql 2005 and try to deserialize from BinaryFormatter. This will be the GOLD, for now a simple serializable-Compress-Decompress-Deserializable is very fine...
But, I´m getting a error:
"Binary stream '0' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization."
Any help?
My Code:
public static void Main()
{
List<string> p3;
List<string> p1 = new List<string>();
p1.Add("Brazil");
p1.Add("Error");
p1.Add("Serializable");
Stream Serial = new MemoryStream();
FileStream fileStream = new FileStream("Teste.bin", FileMode.Create, FileAccess.ReadWrite, FileShare.None);
Processo _Retorno = new Processo();
BinaryFormatter teste = new BinaryFormatter();
teste.Serialize(Serial, p1);
byte[] buffer = new byte[Serial.Length];
Serial.Read(buffer, 0, buffer.Length);
fileStream.Write(buffer, 0, buffer.Length);
fileStream.Close();
byte[] Compremido = Compressor.Compress(buffer);
byte[] Descompremido = Compressor.Decompress(Compremido);
MemoryStream msUnZip = new MemoryStream();
msUnZip.Write(Descompremido, 0, Descompremido.Length);
msUnZip.Seek(0, SeekOrigin.Begin);
BinaryFormatter Serializador = new BinaryFormatter();
p3 = (List<string>)Serializador.Deserialize(msUnZip);:mad:
}
</string></string></string></string>
public static class Compressor
{
public static byte[] Compress(byte[] data)
{
MemoryStream output = new MemoryStream();
GZipStream gzip = new GZipStream(output,
CompressionMode.Compress, true);
gzip.Write(data, 0, data.Length);
gzip.Close();
return output.ToArray();
}
public static byte[] Decompress(byte[] data)
{
MemoryStream input = new MemoryStream();
input.Write(data, 0, data.Length);
input.Position = 0;
GZipStream gzip = new GZipStream(input,
CompressionMode.Decompress, true);
MemoryStream output = new MemoryStream();
byte[] buff = new byte[64];
int read = -1;
read = gzip.Read(buff, 0, buff.Length);
while (read > 0)
{
output.Write(buff, 0, read);
read = gzip.Read(buff, 0, buff.Length);
}
gzip.Close();
return output.ToArray();
}
} Font: http://www.codeproject.com/KB/viewstate/ViewStateCompression.aspx[^]
|
|
|
|
|
JUST for awnser this...
It´s necessary to put
Serial.Seek(0, SeekOrigin.Begin);
Between:
byte[] buffer = new byte[Serial.Length];
Serial.Read(buffer, 0, buffer.Length);
|
|
|
|
|
I have a piece of javascript code that writes to a local file. When this happens, how can I notify a running C# WinForm application so C# app can process the file.
Thanks.
|
|
|
|
|
You could always use a FileSystemWatcher to keep an eye on this file.
|
|
|
|
|
I'm trying to change the system date and time on XP Pro:
In the form's class header I have:
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool SetSystemTime( [In] ref structSystemTime st );
public struct structSystemTime
{
public short wYear;
public short wMonth;
public short wDayOfWeek;
public short wDay;
public short wHour;
public short wMinute;
public short wSecond;
public short wMilliseconds;
}
Then in Form_Load I have:
structSystemTime st = new structSystemTime ();
st.wYear = 2003;
st.wMonth = 5;
st.wDay = 22;
st.wHour = 22;
st.wMinute = 15;
st.wSecond = 08;
SetSystemTime(ref st);
It compiles and runs, but the date/time doesn't change. Anyone know what's wrong?
Everything Makes Sense In Someones Mind
|
|
|
|
|
KMAROIS wrote: It compiles and runs, but the date/time doesn't change. Anyone know what's wrong?
Change the definitions of the fields from short to ushort (unsigned short).
|
|
|
|
|
If fixing the structure doesn't help, does
GetLastWin32Error() return a useful error code?
if (!SetSystemTime(ref st))
{
int errcode = Marshal.GetLastWin32Error();
}
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I changed the struct and it did not work. It returned 1314, which is:
if (!SetSystemTime(ref st))
{
int errcode = Marshal.GetLastWin32Error();
string errorMessage = new Win32Exception(Marshal.GetLastWin32Error()).Message;
MessageBox.Show(errorMessage);
}
Turns out the Sys Admin has restricted users from chaning the date/time.
Now to go find the sys admin....
Everything Makes Sense In Someones Mind
|
|
|
|
|
There is usually a good reason, good luck with the Admin, take your flame proof suit!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Whenever I use WinAPI, the equivelant of any integer (short or int) in API documentation, I always have to use Int32.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
I have the same problem but the marshal tells me that error 57
Have you managed to solve it?
|
|
|
|
|
How can i mask "Internet IP Address" with "C#"
|
|
|
|
|
maliaslam wrote: How can i mask "Internet IP Address" with "C#"
Before you get an answer to this question, you're going to have to do some serious convincing that this is for a legitimate purpose. Why do you need to do this?
|
|
|
|
|
maliaslam wrote: Internet IP Address
Internet Internet Protocol Address
As he said earlier, why do you need this?
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Manas Bhardwaj wrote: Internet Internet Protocol Address
It's to differentiate this from baked bean tin IP address.
|
|
|
|
|
I make "annonymose web browser" so please tell me how to do this
|
|
|
|
|
|
Hi,
How do you build a project of multiple classes and resources using the CSC program from the command line?
Many thanks!
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
csc /?
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.1
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.
Visual C# 2008 Compiler Options
- OUTPUT FILES -
/out:<file> Specify output file name (default: base name of file with main class or first file)
/target:exe Build a console executable (default) (Short form: /t:exe)
/target:winexe Build a Windows executable (Short form: /t:winexe)
/target:library Build a library (Short form: /t:library)
/target:module Build a module that can be added to another assembly (Short form: /t:module)
/delaysign[+|-] Delay-sign the assembly using only the public portion of the strong name key
/doc:<file> XML Documentation file to generate
/keyfile:<file> Specify a strong name key file
/keycontainer:<string> Specify a strong name key container
/platform:<string> Limit which platforms this code can run on: x86, Itanium, x64, or anycpu. The default is anycpu.
- INPUT FILES -
/recurse:<wildcard> Include all files in the current directory and subdirectories according to the wildcard specifications
/reference:<alias>=<file> Reference metadata from the specified assembly file using the given alias (Short form: /r)
/reference:<file list> Reference metadata from the specified assembly files (Short form: /r)
/addmodule:<file list> Link the specified modules into this assembly
- RESOURCES -
/win32res:<file> Specify a Win32 resource file (.res)
/win32icon:<file> Use this icon for the output
/win32manifest:<file> Specify a Win32 manifest file (.xml)
/nowin32manifest Do not include the default Win32 manifest
/resource:<resinfo> Embed the specified resource (Short form: /res)
/linkresource:<resinfo> Link the specified resource to this assembly (Short form: /linkres)
Where the resinfo format is <file>[,<string name>[,public|private]]
- CODE GENERATION -
/debug[+|-] Emit debugging information
/debug:{full|pdbonly} Specify debugging type ('full' is default, and enables attaching a debugger to a running program)
/optimize[+|-] Enable optimizations (Short form: /o)
- ERRORS AND WARNINGS -
/warnaserror[+|-] Report all warnings as errors
/warnaserror[+|-]:<warn list> Report specific warnings as errors
/warn:<n> Set warning level (0-4) (Short form: /w)
/nowarn:<warn list> Disable specific warning messages
- LANGUAGE -
/checked[+|-] Generate overflow checks
/unsafe[+|-] Allow 'unsafe' code
/define:<symbol list> Define conditional compilation symbol(s) (Short form: /d)
/langversion:<string> Specify language version mode: ISO-1, ISO-2, or Default
- MISCELLANEOUS -
@<file> Read response file for more options
/help Display this usage message (Short form: /?)
/nologo Suppress compiler copyright message
/noconfig Do not auto include CSC.RSP file
- ADVANCED -
/baseaddress:<address> Base address for the library to be built
/bugreport:<file> Create a 'Bug Report' file
/codepage:<n> Specify the codepage to use when opening source files
/utf8output Output compiler messages in UTF-8 encoding
/main:<type> Specify the type that contains the entry point (ignore all other possible entry points) (Short form: /m)
/fullpaths Compiler generates fully qualified paths
/filealign:<n> Specify the alignment used for output file sections
/pdb:<file> Specify debug information file name (default: output file name with .pdb extension)
/nostdlib[+|-] Do not reference standard library (mscorlib.dll)
/lib:<file list> Specify additional directories to search in for references
/errorreport:<string> Specify how to handle internal compiler errors: prompt, send, queue, or none. The default is queue.
/moduleassemblyname:<string> Name of the assembly which this module will be a part of
|
|
|
|
|
Hi Guys,
I am wondering if it is possible to search all the computers within a domain or a network to discover all the excel files and then store them in a common location?
I have seen some examples of searching computers in a domain but didn't find any example for file search in a domain.
Can somebody help please?
Thanks
happy coding!
|
|
|
|
|
Why on earth would you do that instead of letting the user decide what should be commonly accessed and what shouldn't be?
|
|
|
|
|
I can see an admin requirement for this but I don't think you are going to achieve it. You need at least read only access to EVERY folder on the network. I imagine if you own the network you could do this, IBM has a tool to check the files on a PC but they turn up with a USB key to do it and I'm pretty bloody sure they would rather do it centrally .
There are a number of enterprise tools out there which require you to register a sheet and it stores it in a database and uses version control and change management on the REGISTERED files only. Serious enterprise money though.
Never underestimate the power of human stupidity
RAH
|
|
|
|