|
Hello all,
I need a program in C#.NET that can do compression and decompression of text files.
Will be much thankful, if u cud help me in getting the same.
Regards,
Manivannan.P
|
|
|
|
|
If depends what compression you want. The most popular is the ZIP format (LZH compression). The most popular ZIP library for .NET is #ziplib[^].
Note that .NET 2.0 will support LZH compression, as well as provide abstract stream classes for other stream compression algorithms.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
ok, so I made a tic tac toe game. But it's really of no use because you have to play against someone else and I don't even know how to have it tell if someone won. Basically I have flat buttons and every time one is clicked, it becomes read only and it it puts an X, and then the next button clicked has the text property of O and so on. I need help creating the code that enables the user to play against the computer. I think this is done using a two-dimensional array, but my skills in c-sharp are quite limited. So any help with the code and tactics the computer would use (in the form of code) would be very helpful. I realize this is kind of a big request, but if you have time, it would be awesome if you could help. You could even publish an article somewhere on the website, that many people would use.(just let me where you publish it if you do)
thank you so much,
Stephen
|
|
|
|
|
If you google for "tic tac toe bot", you'll find lots of discussions and examples in many different languages.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Anyone have any ideea how to host other application in .net ? I start the word/notepad/cmd using process but i want my app to host it not the windows, something like mdi forms; when i minimize the hosted app i wanna go at base in my form not in windows.
Thanks in advance .
|
|
|
|
|
Don't know about notepda but ther are a lot of com components that you can use inside your own forms e.g. Windows media player.
If you are using visual studios then right click on the toolbar and select customize toolbar and you will get tons of com and .net components.
|
|
|
|
|
There's no way for you to "host" the app in your application. You simply cannot redirect where your hosted application's drawing code is going to paint its window. You would have to completely rewrite the Window Manager subsystem of Windows and essentially make your application the new Desktop.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Those are separate applications with their own top-leve windows; you cannot host them. You can only host controls. In the case of Office applications like Word, you can host the Active Document container (pretty much everything) and - if you go to a massive amount of work - even get information to host the toolbars.
This is not supported in .NET, however, not until 2.0 at least (which adds the ActiveDocument control. You can write your own, though, but you must have a good understanding of COM and interoperability with .NET; otherwise, you should try googling the net for examples that already do this.
Also note that you can host the Word OCW control which was designed to be hosted in a web page (OCW == "Office Components for the Web"). That's as easy as customizing your Toolbox in Visual Studio and dragging "Word" onto your form. Now you can host Word documents. You do the same with Windows Media Player as someone else suggested.
Note all applications support this, however: only ActiveX controls are supported.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I have a c# console app and all i want to do is write to a log file when the program ends.
I put my code in the destructor but it doesn't write to the log file. Any ideas why this is happening or how i can solve this?
|
|
|
|
|
|
ok this is my destructor -
~TiffConverterClass()
{
Logger l = new Logger(@"c:\testLog.txt");
l.writeLine(Logger.logType.Info ,"Application has been disposed");
l.Dispose();
}
i have a class variable in TiffConverterClass i.e private Logger log but i figured that maybe when I close the program it gets disposed before it gets to this destructor - thats why i declare it again in the destructor. This destructor is in the same class as the main method.
|
|
|
|
|
The destructor (properly called a finalizer in .NET) should not be used for this kind of thing because it is non-deterministic and when your application ends it is obviously just not being called at all. (I'm not actually sure if it should have been called or not - I simply don't use finalizers. They aren't recommended anyway)
gavinJeffrey wrote:
This destructor is in the same class as the main method
The Main method is static, it doesn't require an instance of the class to operate, so you would never get a finalizer called if that is all you were using.
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
Colin Angus Mackay wrote:
The Main method is static, it doesn't require an instance of the class to operate, so you would never get a finalizer called if that is all you were using.
I do declare a new object of the same class (TiffConverterClass) in the main method. So i definetely instantiate it. But i hear your advice on Finalizers so....
Are there any alternatives to actually get my program to write to a log file just before terminating??
|
|
|
|
|
How about at the end of your Main method?
Do you want to know more?
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
|
|
|
|
|
I tried that but...
the problem is that in my main method I instantiate the class and then call a method of that class that does all the work (this method sets up the timer) but I have to put in a Console.ReadLine() right at the end to stop the program from ending. If i put it before the Console.ReadLine() then it doesn't actually write it when the program ends and if i put it after it never gets there.
|
|
|
|
|
I'm not certain, but this could be something to do with garbage collection (C# destructors don't work the same as C++ destructors - clicky[^]) - apparently there's no guarantee that a class's destructor will ever be called (so maybe this is your problem)
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Very easy.. replace delegate with anything you need
using System;
namespace ConsoleApplication1
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit);
}
private static void CurrentDomain_ProcessExit(object sender, EventArgs e)
{
Console.WriteLine("Bye");
}
}
}
-
Drew
|
|
|
|
|
Hi,
I am using OpenFileDialog to browse the file path ans select the file path in textbox1 and enter ID and another textbox2 in windowform when user opens first time then next time when they open this form i want the filename and ID to appear automatically whatever they entered before. I know how to use in asp.net with config file but with windowforms any idea ???
Thanks,
|
|
|
|
|
you can set the contents of a text box using it's .Text member
i.e.
when you init the form:
textbox2.Text = SomeStringVariable;
and then when you're done with the form
SomeStringVariable = textbox2.Text;
(so just keep this string in a static variable in your form's class, and it'll remember it)
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
Hello
I have a SQL statement which is long. How do l write it so that it is on serveral lines.
This is what l have tried to do.
<br />
CnnStr = "SELECT student.studentID, student.FirstName, student.LastName" +<br />
"book.bookID, book.Title" +<br />
"FROM student, book" +<br />
"WHERE student.studentID = book.studentID";<br />
This does not work, and anyone tell me how to do this.
Many thanks in advance,
Steve
|
|
|
|
|
add at the beginig and end of an string a space (0x20 char)
your code needs to look like this in order to work
<br />
CnnStr = " SELECT student.studentID, student.FirstName, student.LastName " +<br />
" book.bookID, book.Title " +<br />
" FROM student, book " +<br />
" WHERE student.studentID = book.studentID ";<br />
I hope you understand...
By the way... visit http://nehe.gamedev.net[^]
|
|
|
|
|
You're missing a comma after Student.LastName
--
Help me! I'm turning into a grapefruit!
Phoenix Paint - back from DPaint's ashes!
|
|
|
|
|
To consolidate the above answers:
CnnStr = "SELECT student.studentID, student.FirstName, student.LastName," +
" book.bookID, book.Title" +
" FROM student, book" +
" WHERE student.studentID = book.studentID";
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
This may be a dumb question, but does your statement work when it is just one long line?
alphanorm
|
|
|
|
|
Three things:
1. You need to leave the proper spaces between things like Title and FROM.
2. You need to add a comma after LastName.
3. You can also use the @ sign in front of the string to avoid the extra quotes and + signs:
CnnStr = @"SELECT student.studentID, student.FirstName, student.LastName, <br />
book.bookID, book.Title <br />
FROM student, book <br />
WHERE student.studentID = book.studentID";
Regards,
Alvaro
Our enemies are innovative and resourceful, and so are we. They never stop thinking about new ways to harm our country and our people, and neither do we. - George W. Bush
|
|
|
|