|
It is in the end just bits on a disk. If someone wanted to they could read it (unplug/cause a kernel memory dump, reboot and read the file). The file locking mechanim is strictly not a security feature: it is there to maintain a consistent IO for running applications. If you really want a file that is secured, then you must use security mechanism.
|
|
|
|
|
Hi!
I have already posted this question in this forum, but I have not yet got any response. So i have decided to post it again.
I am trying to create a RubberBand when cropping an image from a PictureBox using the mouse.
All is well when drawing the rectangle with the help of MouseDown, MouseMove and MouseUp events.
I don't know how to maintain aspect ratio of the rectangle when drawing it over the picture box (as in Adobe PhotoShop).
I can mail you my code for your reference.
Any Idea will be helpful.
-- modified at 12:12 Tuesday 25th October, 2005
|
|
|
|
|
I would think a simple approach to doing this would be to define a double aspect which you set to height/width of the original image (you'd need to put some checks in to avoid possible divide by zero exceptions here).
Then when tracking the rectange take whichever is largest of the (absolute) new width or new height and determine the value of the other variable (new height or new width) by multiplying/dividing this by aspect ...if that makes any sense?
If you think of a straight line being defined as y = mx + c, the gradient (m) of a line going through the bottom left and top right corners of the rectange should remain constant whatever the size of the rectangle.
Rob Philpott.
|
|
|
|
|
Memory Stream Problem :
I have a component class which access a local file and writes the contents of the file to a Memory using MemoryStream. This
is accomplished a method called "Initialize()". This method returns the MemoryStream object. This Class is shown below:
using System;
using System.IO;
using System.Net;
using System.Text;
namespace MemWriterComponent
{
public class MWC
{
//Private variables
private MemoryStream ms; //Used for writing to memory
private FileStream fs; //Used for reading local file
private string data; //string variable for holding data
public MWC()
{
//initialize private variables
ms = new MemoryStream();
}
//public method Initialize() which reads the local file and returns
//memory stream
public MemoryStream Initialize()
{
string fileName =
"D:\\NET_Prog_Samples\\Chapter2\\MemoryStreamExample\\MemWriterComponent\\bin\\Debug\\testy.txt";
//initialize the file stream object
try
{
fs = new FileStream(fileName,FileMode.Open,FileAccess.Read );
//read the contents of the file
byte[] bytesIn = new byte[fs.Length];
fs.Read(bytesIn,0,bytesIn.Length);
data = Encoding.ASCII.GetString(bytesIn);
//close fs
fs.Close();
fs= null;
//Write the read data into the memory
byte[] bytesOut = new byte[data.Length];
bytesOut = Encoding.ASCII.GetBytes(data);
ms.Write(bytesOut,0,bytesOut.Length);
return ms;
}
catch(Exception ex) {
Console.WriteLine(ex.ToString());
return new MemoryStream();
}
}
}
}
The second class (Console Application) tries to retrieve the contents from memory location. I made a reference to
MemWriterComponent, initialized the object and then tries to retrieves the contents from memory. This class is shown below:
using System;
using MemWriterComponent;
using System.Text;
using System.IO;
namespace MSReader
{
///
/// Summary description for Class1.
///
class MSR
{
[STAThread]
static void Main(string[] args)
{
try
{
//initialize the MWC component
MemWriterComponent.MWC mw = new MemWriterComponent.MWC();
MemoryStream msReader = mw.Initialize();
byte[] bytesIn = new byte[msReader.Length];
msReader.Read(bytesIn,0,Convert.ToInt32(msReader.Length));
string dataIn = Encoding.ASCII.GetString(bytesIn,0,bytesIn.Length).ToString();
Console.WriteLine(dataIn);
//clean up code
msReader.Close();
mw=null;
Console.ReadLine();
}
catch(Exception ex) { Console.WriteLine(ex.ToString());}
}
}
}
Problem is running a client doesn't give any error(s). But also doesn't print any thing.
If i try to retrieve Size of Memory Stream using Console.WriteLine( msReader.Length). the output is 611 bytes... which is
incidently the size of the file "testy.txt".
What am i doing wrong?
any suggestions???
|
|
|
|
|
farhan1976 wrote: Problem is running a client doesn't give any error(s). But also doesn't print any thing.
well you didnt write anything to print though it normal...
farhan1976 wrote: Problem is running a client doesn't give any error(s). But also doesn't print any thing.
If i try to retrieve Size of Memory Stream using Console.WriteLine( msReader.Length). the output is 611 bytes... which is
incidently the size of the file "testy.txt".
well it sure does or it would be a problem ^^
|
|
|
|
|
In the component Class, I did write data to the Memory stream - I opened Local File and read its contents -> string variable : data
//read the contents of the file
byte[] bytesIn = new byte[fs.Length];
fs.Read(bytesIn,0,bytesIn.Length);
data = Encoding.ASCII.GetString(bytesIn);
//close fs
fs.Close();
fs= null;
//Write the read data into the memory
byte[] bytesOut = new byte[data.Length];
bytesOut = Encoding.ASCII.GetBytes(data);
ms.Write(bytesOut,0,bytesOut.Length);
return ms;
|
|
|
|
|
my guess is that you need to do a ms.position=0; before returning ms.
|
|
|
|
|
hi
I need write a progam in .Net (c# or vb.net):
The program should display in a monitor(tv) video files(e.g. *.avi, *.mpg, ...) and also display TV channnels(analogical signal) depending on a schedule(user defined)
what I must use? ... ¿Managed DirectX?
Helpme please
|
|
|
|
|
hi
I need write a progam in .Net (c3 or vb.net):
The program should display in a monitor(tv) video files(e.g. *.avi, *.mpg, ...) and also display TV channnels(analogical signal) depending on a schedule(user defined)
what I must use? ... ¿Managed DirectX?
Helpme please
|
|
|
|
|
Hello,
Is there a way of changing the captions of MessageBox buttons to something else? Or, if I want different buttons' captions I have to create my own dialog box?
Thank you.
|
|
|
|
|
You'll need to create your own dialog box. The MessageBox class is pretty well sealed up and you can't do much with it beyond what it's supposed to do. It shouldn't take more that five minutes to whip up your own dialog box class in Visual Studio anyway.
|
|
|
|
|
|
Is there a tutorial on the different events and their sequence of firing for a typical windows forms form?
I am curious about comparing the event sequences from MFC to windows forms.
.............................
There's nothing like the sound of incoming rifle and mortar rounds to cure the blues. No matter how down you are, you take an active and immediate interest in life.
Fiat justitia, et ruat cælum
|
|
|
|
|
i have a problem i need to diasble the print screen in my application.
i have been program my application by using C# language and i need to prevent any user from copying any desplayed image on it.
i have been search alot but i couldnt find any.
i try to learn programming what ever i had i feal that i did'nt get anything
|
|
|
|
|
What do you mean by "disable the print screen"? You want to stop people copying text off your application using the clipboard? You want to stop people taking screenshots (in which case, I think you're out of luck!)?
|
|
|
|
|
You can disable print screen keys (PrtScrn and Alt-PrtScrn) by redirecting the hot keys to your applications main window. But there is no way you can't stop another application, like ScreenGrabber, from grabbing the screen, and your graphic images.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I thought dvd player apps could prevent 3rd party apps from doing screen grabs. I assume they do it by accessing hardware at a lower level than the win32api provides access to.
|
|
|
|
|
Not really. You're grabbing exactly what you should, the image in the frame buffer. The frame buffer just happens to be blank in the video window. The video you're seeing isn't being shown in this frame buffer, but is an overlay rendered by a different part of the video card.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
you have been mentioned somthing about redirecting the hot key, i have been searched for this solution but i didnt find any thing help full for how to do that with c#. it's ok for me to prevent the people from doing it at least in the easy way, so here i have a new Q how could i use the registry hot key with c#
thanks for help, a little help do alot
i try to learn programming what ever i had i feal that i did'nt get anything
|
|
|
|
|
|
Im using Visual studio.net 2003 language C#
i want to insert a readonly dataRow in my Datatable(which is bound to the grid)how do i do that?
thanks
regards paula
|
|
|
|
|
Use the following:
<br />
yourTable.DefaultView.AllowNew = False<br />
|
|
|
|
|
Hello,
I am trying to hide a certain column in a DataGrid, but to no avail. Here is the part of the code:
<br />
this.dataview.Table.Columns["VersionID"].ColumnMapping = MappingType.Hidden;<br />
this.dataGridCashFlow.DataSource = this.dataview;<br />
Any ideas, why it would not work? Column VersionID still shows up in the DataGrid
Thank you
|
|
|
|
|
Add a DataGridTableStyle object to your DataGrid and include only the columns you want visible in it's GridColumnStyles collection.
|
|
|
|
|
use tablestyle and set the column width = 0
***********example of some of the code************
tsGrid.MappingName = "data";
// Add it to the datagrid's TableStyles collection
dgClientView.TableStyles.Add(tsGrid);
// Hide the first column (index 0)
dgClientView.TableStyles[0].GridColumnStyles[0].Width = 0;
Don't know if this is what your looking for?
marcelw
|
|
|
|