|
No I will not, it's a bad idea.
|
|
|
|
|
Is anybody aware of a bug (and a fix) in VS 2005 SP1 that generates errors in datasets when adding an insert/update/delete query. The error is "reference is not set to an instance of an object" (usually line 1) and is generated because the "Name" attribute is not saved in the xml file.
Sometimes, simply loading the dataset in Visual Studio, and saving it clears all the "Name" attributes in the xml; and this has happened on multiple computers.
Mihai,
|
|
|
|
|
hi there,
i m making an app that need to decompress Zlip file from File data in byte[] in a specified format
i.e.
char {4} - Header (l33t)
uint32 {4} - Decompressed File Size
byte {X} - ZLib Compressed File Data
// WHEN DECOMPRESSED
char {2} - Header (BG)
uint32 {4} - Archive Size [+8]
byte {X} - Unknown
to read this file, i created a binary reader and read what i can but i m unable to decompress it
the codes to read :
BinaryReader br = new BinaryReader(File.Open(@"C:\Documents and Settings\xmen\Desktop\g.age3scn", FileMode.Open));
string header = new string(br.ReadChars(4));
int filesize = br.ReadInt32();
byte[] filedata = br.ReadBytes(filesize);
can someone tell me how can i decompress it?
Becoming Programmer...
|
|
|
|
|
Have you tried Google[^] to look for a .NET wrapper around the zlib libraries?
|
|
|
|
|
What is this Google you speak of?
|
|
|
|
|
It's this new-fangled contraption that automagically gives you the answer to any question you ask. I know, it's heresey, isn't it?
|
|
|
|
|
And it really works[^]...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
yep, but didnt find anything about Zlib
Becoming Programmer...
|
|
|
|
|
|
opps..!! i forgot to click on it
Becoming Programmer...
|
|
|
|
|
I have myObject and I want to know whether it is an instance of ICollection<T> for some unknown T. In simple cases, this might suffice:
myObject.GetType().GetGenericArguments()
However, I have many classes like this:
class XCollection : MySuperCollection<X>
class YCollection : MySuperList<Y>
So myObject's immediate type may not have any generic arguments. Remembering that one class my implement ICollection<T> for many types T, I'd like a method like this:
/// <returns>
/// The value of GetGenericArgs(), a Type[], for each specific type of the
/// given genericType that is implemented by subType.
/// </returns>
Type[][] GetGenericArgs(Type genericType, Type subType)
Which could be used like this:
Type[][] elementTypes = GetGenericArgs(typeof(ICollection<>), myObject.GetType())
// elementTypes == new Type[][] { new Type[] { typeof(X) } };
One way is to require genericType to implement ICollection<>, check for methods named 'GetEnumerator', get each possible T implied by these methods, and then check whether myObject is an instance of ICollection<T> for each specific possibility. I can implement this, and I'm sure it will work, but it's Wrong. Is there an appropriate way to do this?
|
|
|
|
|
Are you trying to determine if it implements ICollection<T> or a concrete instance of ICollection<T> (say ICollection<int> )?
You could try using the <a href="http://msdn2.microsoft.com/en-us/library/system.type.isassignablefrom.aspx">IsAssignableFrom</a>[<a href="http://msdn2.microsoft.com/en-us/library/system.type.isassignablefrom.aspx" target="_blank" title="New Window">^</a>] method to determine if it implements any ICollection<T> or the IsGenericType[^] property?
You could also take a look at the ContainsGenericParameters[^].
|
|
|
|
|
I'm trying to determine if it implements ICollection<>, not a specific type like ICollection<int>.
IsAssignableFrom is a nice magical method, but it only works for specific types.
Anyways, I think I found the right way to do what I want (after, of course, putting my question in a public space...). Thanks for your help. Here's my solution, and the problem stated in sharper terms:
Supposing type X as follows,
class X
{
private class WackyClass<T> : ICollection<T>, IList<int> { }
private class XList : WackyClass<string> { }
static public readonly object Data = new XList();
}
Implement this method, which has no access to X's private types:
/// <example><code>
/// Type[][] args = GetGenericArgs(X.Data, typeof(ICollection<>));
/// Assert(args == new Type[][] {new Type[] {typeof(string)}, new Type[] {typeof(int)}});
/// </code></example>
Type[][] GetGenericArgs(Type subType, Type genericType);
Here is an implementation I feel much better about
if (genericType.IsGenericTypeDefinition == false)
if (genericType.IsGenericType && genericType.IsAssignableFrom(subType))
return new Type[][] { genericType.GetGenericArguments() };
else
return new Type[][] { };
else
{
IEnumerable<Type> candidates;
if (genericType.IsInterface)
candidates = subType.GetInterfaces();
else
candidates = Iterators.Traverse<Type>(subType, "BaseType");
List<Type[]> result = new List<Type[]>();
foreach (Type candidate in candidates)
if (candidate.IsGenericType && candidate.GetGenericTypeDefinition() == genericType)
result.Add(candidate.GetGenericArguments());
return result.ToArray();
}
|
|
|
|
|
I have a window that when it is minimized it is displayed in system tray. The problem is that from time to time I have to show different messages via a messagebox and the message box doesn't appear. When the window is maximized the messageboxes appear.
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
You need to display the message box on the desktop. You can do this with this overload of the Show()[^] method. This overload allows you to specify additional options[^]. You want to specify the DefaultDesktopOnly option and (I think) pass null for the owner.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
Hi all
while am writing to a text file using the way
PrintTextWrite.WriteLine(PSLNO.PadRight(3) + " " + PKCODE.PadRight(14) + " " + PITEMNAME.PadRight(45) + " " + PQTY.PadLeft(40) + " " + PRT.PadRight(11) + " " + PTOT1.PadLeft(20));
when PITEMNAME length increases there is alignment problem for PQTY & PRT & PTOT1
am i doing it proper way or is there any other way to set format for text file ???
thanks in advance
|
|
|
|
|
rowdykuttan wrote: when PITEMNAME length increases there is alignment problem for PQTY & PRT & PTOT1
Then check the lenth first, and if it is too large then truncate it. Or increase the space in the format.
|
|
|
|
|
am sending this text file to a DOT MATRIX printer, that too to a PREPRINTED STATIONARY, is there any way i can specify X & Y positions in text file or printer
|
|
|
|
|
rowdykuttan wrote: am sending this text file to a DOT MATRIX printer, that too to a PREPRINTED STATIONARY
You might like to specify that next time. It helps people understand your problem.
If you have a fixed external constraint like the size of preprinted paper then you have to truncate the information printed. Lop off a few characters. You'll find an appropriate method on the string class. Subseq, Substring or some such thing.
rowdykuttan wrote: is there any way i can specify X & Y positions in text file
If the file is formated as fixed length lines then you can calculate any XY position in the file and Seek to it.
(Y*LineLength) + X
LineLength includes the two character line feed and carriage return characters. It also assumes a fixed 8-bit character encoding.
|
|
|
|
|
If PITEMNAME's length is > 45, it is going to push everything over. You could truncate at 45 or you look at all the PITEMNAME values (assuming you are looping and trying to dump out data in columns) and set the pad accordingly rather than specifying 45.
If you are limited to your width and 45 is max, truncating is what I'd do, probably.
Good Luck!
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
Are you looking to do something like this?
1 George Washington April 30, 1789
2 John Adams March 4, 1797
3 Thomas Jefferson March 4, 1801
4 James Madison March 4, 1809
5 James Monroe March 4, 1817
6 John Quincy Adams March 4, 1825
7 Andrew Jackson March 4, 1829
8 Martin Van Buren March 4, 1837
9 William H. Harrison
March 4, 1841
10 John Tyler April 4, 1841
|
|
|
|
|
yes exactly but for William H. Harrison its comming in next line, i have left space for it like
1 George Washington April 30, 1789
2 John Adams March 4, 1797
3 Thomas Jefferson March 4, 1801
4 James Madison March 4, 1809
5 James Monroe March 4, 1817
6 John Quincy Adams March 4, 1825
7 Andrew Jackson March 4, 1829
8 Martin Van Buren March 4, 1837
9 William H. Harrison March 4, 1841
10 John Tyler April 4, 1841
i have enough space like this after name, plz tell me how to do it
|
|
|
|
|
You'll have to use <pre> tags in your response so I can see your formatting. Just modify your response, then I'll have another look.
|
|
|
|
|
1 George Washington April 30, 1789
2 John Adams March 4, 1797
3 Thomas Jefferson March 4, 1801
4 James Madison March 4, 1809
5 James Monroe March 4, 1817
6 John Quincy Adams March 4, 1825
7 Andrew Jackson March 4, 1829
8 Martin Van Buren March 4, 1837
9 William H. Harrison March 4, 1841
10 John Tyler April 4, 1841
|
|
|
|
|
Are you saying you want to adjust all the lines to account for the longest?
|
|
|
|