|
I don't think, you can do this. And even if you did, the user could still press Ctrl + Alt + Del (which can't be intercepted as far as I know), open Task Manager and kill your application.
I would suggest another appoach. Give the user only minimal rights (just to his user directory). Start your application under a different user who has access to the necessary directories. Require a password to close your application. Under this setup the Task Manager is of no use because the user can't kill other users' processes.
The good thing about pessimism is, that you are always either right or pleasently surprised.
modified 19-Jul-13 6:17am.
|
|
|
|
|
aymen amri wrote: but with this solution the windows expolorer still work, for example when I push the keybord start button it still works The keyword was "Kiosk mode". DuckDuckGo it, and you'll come across checklists like this one[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi all
If I have a web page URL string in C#, how to save the web page as MHTML extension?
|
|
|
|
|
First, the mandatory question since you don't mention it in your post:
What have you tried?
I remember I did something kind of like what you want about a year ago, since I didn't have a clue, I googled (don't remember the specific query), and one of the first links was a MSDN page with an example to it.
What I mean is: please show/tell us what you've done, and what is the specific problem that you have, so we know that you are indeed making an effort and not just wasting everyone's time.
Now, I'm not just gonna lecture you and give you nothing. Look for info on:
How to read/write files in C#
How to get the HTML contents of a web page
You'll need to get acquainted with the following namespaces/classes:
System.Net[^]
System.IO[^]
Filestream[^]
WebClient[^]
If you think you can do a thing or think you can't do a thing, you're right - Henry Ford
Emmanuel Medina Lopez
|
|
|
|
|
|
Hi All,
I have created a stored procedure which returns dynamic columns, i need to map this to the EF to populate the data on a KendoUI Grid. How can i do it?
I need to create the entities based on the number of columns returned from the stored procedure, because my columns are always dynamic and change frequently, so i cannot create a fixed custom entity in EF.
if I have used Normal Ado.net it will return datatable format.In this we can't bind kendoui using Datatable.
Any help would be appreciated Please respond ASAP.
|
|
|
|
|
|
I Need to execute a procedures using C# Command
like this
string cmd = @"Create Or Replace Procedure Fix wrapped
a000000
230
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
7
b5 db
D72BlwrV1gjrUSfLEEUQzh3CcxkwgzJfCsvhf46iLc3qX7ovyA5450Xt2d/eEhO83Ttm+5lG
yjOGJunKydtdR733WyVs09T4gOwU6QIvvFfp8+3D9WWHGKKnQF8AX3JfGH/C1tGABS8+oMDe
i/GE+pinMauuHrnwHUUBJhPUUAEOyLJ4PUJmKP+2lUY8eTpOwbHNkjDgbSz3sX3qD4jh0UQ="
command.CommandTimeout = 0;
command.CommandText = cmd;
command.ExecuteNonQuery();
this code done successfully but the result when execute the fix procedures on the pl\sql
ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object AUDI.FIX is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Or show me message the procedures is corrupted
So there is any Idea
|
|
|
|
|
I would like to do a image stitching program(which is like a panoramic image after capturing) that is able to capture and stitching at the same time, but I am using the example codings provided by EMGU CV and the codings are unable to stitch images vertically and also Axis Communication PTZ 214 Camera for the captured images.I will be using imagebox control and axis media control. Can somebody please help?
modified 18-Jul-13 5:28am.
|
|
|
|
|
Hello All,
need to convert Word Document Content Like Mail Merge and Convert It in to OPEN XML, please, do the need full.
Thanks In Advance
|
|
|
|
|
If by "do the needful" you mean write your code for you, that's just not going to happen.
You haven't said anything at all about where you're stuck in this process, so it's pretty much impossible to tell you what's going on.
|
|
|
|
|
Dave, fyi, the expression "do the needful" is a Hindi-English idiom often used in correspondence; in this case it may not have the meaning of "gimme codez" ... or, it might
yours, Bill
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
|
|
|
|
|
I know where it's from and it can be traced back to about the 1700's in British English.
But, since the OP doesn't specify anything at all about what he's looking for, I just had to guess and us an "if" in preface to the most likely possibility.
|
|
|
|
|
Hi Dave,
I am delighted to know you are familiar with such constructions (the more common form, I believe, is "do the necessary") [^]. I'm not sure whether, technically, these (now archaic) forms qualify as calques, and/or Anglicisms.
Have you lived in India, or is there a family connection with the Raj ?
Hope my response to you did not seem patronizing
yours, Bill
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
|
|
|
|
|
BillWoodruff wrote: Have you lived in India, or is there a family connection with the Raj ?
Oh God, no! I just went and did the homework to find out my it's so popular in India, and, to a lesser extent, South Asia English.
BillWoodruff wrote: Hope my response to you did not seem patronizing
No, no. We're good!
|
|
|
|
|
Hi Meetnneel,
Please describe what you have done so far, post the code you have written so far, and discuss what specific problems you are having with it.
yours, Bill
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
|
|
|
|
|
I am successfully using .NET's BinaryFormatter to serialize a very complex object (an instance, at run-time) into a MemoryStream, and I can save that to a file, and then de-serialize the file back into an instance of the object.
Then, I wanted to add compressing the MemoryStream using GZip [1], before saving it to a file.
I am, without compile- or run- time error, using .NET's GZip facility to GZip the created MemoryStream, and then save it to a disk file.
To summarize the save-to-file sequence:
1. use BinaryFormatter to serialize the object to a MemoryStream
2. use GZip to compress the MemoryStream
3. write the Gzipped MemoryStream to disk
I've already learned the hard way that there is a quirk in using GZip in .NET in compressing [^].
I verify that the file is written, and it appears to have been "shrunk" by the GZip facility.
But, when I try to reverse the process, to essentially deserialize (recreate) the object by:
1. reading the Gzipped saved file into a MemoryStream
2. using GZip's Decompress on the MemoryStream
3. using BinaryFormatter to deserialize the MemoryStream, which I then cast into the Type of the original object: fail.
The point I am stuck at is expressed in this code:
using (GZipStream deCompressionStream = new GZipStream(new MemoryStream(), CompressionMode.Decompress))
{
deCompressionStream.CopyTo(newMemoryStream);
}
BinaryFormatter bFormatter = new BinaryFormatter();
object obj = bFormatter.Deserialize(newMemoryStream); Thanks in advance for any advice.
yours, Bill
[1] I set out to explore using GZip as a way to increase my general knowledge of .NET's stream facilities, and after learning how to successfully use Mehdi Gholam's fastBinaryJSON work here on CP, and using the MiniLZO class in Mehdi's Raptor Document Store.
“Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929
|
|
|
|
|
You're passing an empty MemoryStream to the GZipStream s constructor. You need to pass the stream containing the previously compressed data instead.
using (var fileStream = File.OpenRead(@"Path\To\Your\File.bin"))
using (var deCompressionStream = new GZipStream(fileStream, CompressionMode.Decompress))
{
var bFormatter = new BinaryFormatter();
object obj = bFormatter.Deserialize(deCompressionStream);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard, thanks very much for your example !
Your deserialization code is one of the first variations I tried, and it fails to deserialize with an error: "The magic number in GZip header is not correct. Make sure you are passing in a GZip stream."
Clearly my Gzipping is not being done properly. This is confirmed by this experiement: if I modify your code like this:
using (var fileStream = File.OpenRead(filePath))
using (var deCompressionStream = new GZipStream(fileStream, CompressionMode.Decompress))
{
var bFormatter = new BinaryFormatter();
object obj = bFormatter.Deserialize(fileStream);
return null;
} That confirms to me I did not GZip properly.
I tried several variations of GZipping found on MSDN, and StackOverFlow: almost all these examples use source.CopyTo(destination) in some form, within the using statements bracketing the use of GZipStream, evidently for the reason there is a known problem with GZipping not being completed fully until after it exits the 'using statement closure, as referenced here: [^].
So, the burden shifts back to finding the correct way for Gzipping.
thanks again for your time, Bill
|
|
|
|
|
You're copying streams which isn't required; they're based on the decorator-pattern. Below example should work (albeit the GZipped version will be bigger since it's a small class)
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using System.IO.Compression;
[Serializable()]
class SumTestClass
{
public int TestInt { get; set; }
public string TestString { get; set; }
public SumTestClass()
{
TestInt = 42;
TestString = "Hello World";
}
}
static class Program
{
static BinaryFormatter bf = new BinaryFormatter();
static void Main(string[] args)
{
object thingyToSerialize = new SumTestClass();
using (var ms = new FileStream("C:\\Temp\\Test.zip", FileMode.Create))
using (var zs = new GZipStream(ms, CompressionMode.Compress, leaveOpen: true))
{
bf.Serialize(zs, thingyToSerialize);
Console.WriteLine("Stuff saved");
}
using (var ms = new FileStream("C:\\Temp\\Test.zip", FileMode.Open))
using (var zs = new GZipStream(ms, CompressionMode.Decompress, leaveOpen: true))
{
SumTestClass testResult = bf.Deserialize(zs) as SumTestClass;
Console.WriteLine("String: {0}\nInt: {1}", testResult.TestString, testResult.TestInt);
}
Console.ReadLine();
}
} Hope it helps a bit, yell if it doesn't
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks, Eddy !
Your code works with a MemoryStream that has been Gzipped, Serialized, and written to a file.
The 'leaveopen parameter ... in both gzip, and un-gzip ... appears to be redundant: my implementation of your code works with, or without, them.
It compresses a 9mb object=>source-stream to a little over 3mb disk file, whether Compression setting is 'Fastest, or 'Optimal.
"Raising the stakes" from 100k to 1 million total objects yielded a 98+ megabyte MemoryStream that Gzipped to a 30.6mb file with both 'Optimal, and 'Fastest compression. That does make me question the efficiency of Gzip in .NET.
But (hypothesis), perhaps the complex object I am Gzipping and Serializing is, by its nature not highly compressible ?
It is much better to have working code you don't quite understand, than to have code you believe you understand, and expect to work, that does not work
When I feel like I fully understand how I "strayed onto the wrong path" for so many hours, yesterday, and understand exactly why your code works, I feel I should write up a Tip-Trick for CP.
I didn't realize that by using a ".gz" extension to the files I created I was creating something that could be opened with WinRar !
yours, Bill
~
"This isn't right. This isn't even wrong." Wolfgang Pauli"
|
|
|
|
|
You're welcome
BillWoodruff wrote: "Raising the stakes" from 100k to 1 million total objects yielded a 98+ megabyte MemoryStream that Gzipped to a 30.6mb file with both 'Optimal, and 'Fastest compression. That does make me question the efficiency of Gzip in .NET. Alternatively, one could launch an external process and wait for the command to finish. And suddenly, one can easily switch out the ZIP and try an ARJ, or a LHArc
BillWoodruff wrote: I feel I should write up a Tip-Trick for CP. Please do
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Alternatively, one could launch an external process and wait forthe command to finish. And suddenly, one can easily switch out the ZIP and try an ARJ, or a LHArc I have thought about experimenting with launching something like 7-Zip via Process.Start, as suggested (but never detailed) on the 7-Zip discussion forums, but I wonder if, in using any externally launched process, the (possibly required) transfer of the stream to be compressed, or the creation of a "temp" file to hold the stream, before invoking the external process' facilities, would add an "overhead" that would negate its benefit.
I have SharpCompress, found here on CodeProject [^], working, but am not seeing any radical improvement in the current test case over .NET's built-in GZip.
Yesterday I spent a few hours trying to get SharpZipLib [^] working in VS 2012, FrameWork 4.5, without success. But, I'll try that again today.
thanks, again, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
modified 19-Jul-13 1:10am.
|
|
|
|
|
BillWoodruff wrote: would add an "overhead" that would negate its benefit. To answer that, one needs to investigate both overhead and benefit. Yes, it does introduce a slight overhead - but not very much if you hide the console-window. Consider it an isolated, switchable, heavyweight instance of a thread.
BillWoodruff wrote: SharpCompress, SharpZipLib Let's also add DotNetZip[^]. And LZMA[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
See http://www.virtualdub.org/blog/pivot/entry.php?id=335[^] for how much it sucks.
There are various 3rd party deflate libs that suck less, I recommend SharpZipLib (nice license, too).
Though personally I recommend not using the built-in serialization in the first place and just dumping your raw data in a stream. It's a little more work up-front, but it's more flexible, a lot faster, and your data format will actually make sense (which is not always important of course). You can still put it through Deflate of course, I tend to do that (easier than explicitly storing sparse arrays and such).
|
|
|
|
|