|
I am new to C# and need some help with FileStream and BufferedStream . I am building a XML editor using SharpDevelop, the editor will be used to encrypt and decrypt files (custom zip files which are XML, and pictures). Only one person should have access to these files at a time and we want to make sure that everything is cleaned up after someone opens the file. Right now I am sure a FileStream to do all of this, I decrypt the file to a folder using SharpZipLib the files are then loaded into the XML editor, once the person closes the file it then takes that folder encrypts all the files and delete the temp folder I was using.
Would the BufferedStream be better?
|
|
|
|
|
Hey all,
I got a window that is 25px in height, and want it to dock to the screen bottom (so the height is 25px, and the width is 100%), it's because I'm making a RSS newsticker, and want it to slide at the bottom of the screen.
Thanks.
Best Regards,
Elias Sørensen
|
|
|
|
|
is this a windows form ??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
Yes, it's a windows form with no border style.
|
|
|
|
|
try this on form load:
this.Location = New Point(0, Screen.PrimaryScreen.Bounds.Height - thid.Height);
this.Width = Screen.PrimaryScreen.Bounds.Width;
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I've tried this:
private void Form1_Load(object sender, EventArgs e)
{
this.Location = New Point(0, Screen.PrimaryScreen.Bounds.Height - thid.Height);
this.Width = Screen.PrimaryScreen.Bounds.Width;
}
But I get an error ; expected.
Sorry if I've done it wrong, only made c# in 2 days 
|
|
|
|
|
Hello,
I think you only made "fat finger" errors!
New -> new
thid.Height -> this.Height
this.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - this.Height);
this.Width = Screen.PrimaryScreen.Bounds.Width;
All the best,
Martin
|
|
|
|
|
Thanks! It is working! BUT! I could't find the window.. Because it was placed behind the process bar (it was only because I got aero, that i could see it). Do you know how to fix that?
|
|
|
|
|
The problem is in the "Y" axis location.
Remember Y = "down the screen".
this.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - this.Height);
sets a location specified as x,y points.
try:
this.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - (this.Height / 2) );
You should see your line in the middle of the screen. Adjust the second parameter
to be where you want it.
|
|
|
|
|
It didn't work perfect, but i tried to use:
this.Location = new Point(0, Screen.PrimaryScreen.Bounds.Height - (this.Height + 30));
And that works perfect.
But! If i make the processbar bigger, it follows, but if i make it smaller, it is the same place as before, do you understand?
|
|
|
|
|
Try this:
this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
|
|
|
|
|
Doesn't work when i'm doing this:
this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
this.Width = Screen.PrimaryScreen.Bounds.Width;
this.Height = 22;
Have i made a mistake?
|
|
|
|
|
Since the code I gave you uses the Height of the object, you need to set the height before executing that line.
--
this.Height = 22; //this done first
this.Width = Screen.PrimaryScreen.Bounds.Width; //moved here to keep height and width in the same code locations
this.Location = new Point(0, Screen.PrimaryScreen.WorkingArea.Height - this.Height);
|
|
|
|
|
Works perfect! Thank you very much!
|
|
|
|
|
Very good idea with the WorkingArea.
Never heard of it before!
Got my 5 for that!
All the best,
Martin
|
|
|
|
|
I couldn't respond to your email because you haven't confirmed your address.
I'm glad to see you got your answer.
|
|
|
|
|
how to enter the values in rows o a datgrid in deviceapplication.I am trying to enter values in rows but i m not able to edit anything within datagrid.
|
|
|
|
|
Check that the readonly property of the datagrid is set to false.
|
|
|
|
|
there is no such property as Readonly in deviceapplication
|
|
|
|
|
Hi!
If i make a TCP server and i try to connect, the firs time it succeed but then i get an error message: "No connection could be made because the target machine actually refuse it".
<br />
private void AddLine(TextBox tb, string text)<br />
{<br />
if (tb.InvokeRequired)<br />
{<br />
AddLineDel d = new AddLineDel(AddLine);<br />
this.Invoke(d, new object[] { tb, text });<br />
}<br />
else<br />
tb.Text += "\r\n" + text;<br />
}<br />
<br />
private void Listen_button_Click(object sender, EventArgs e)<br />
{<br />
Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);<br />
IPEndPoint ipep = new IPEndPoint(IPAddress.Any, port);<br />
<br />
sock.Bind(ipep);<br />
sock.Listen(2);<br />
sock.BeginAccept(new AsyncCallback(AcceptConn), sock);<br />
}<br />
<br />
private void AcceptConn(IAsyncResult iar)<br />
{<br />
Socket oldserver = (Socket)iar.AsyncState;<br />
client = oldserver.EndAccept(iar);<br />
AddLine(textBox1, "Connection from:" + client.RemoteEndPoint.ToString());<br />
Thread receiver = new Thread(new ThreadStart(ReceiveData));<br />
receiver.IsBackground = true;<br />
receiver.Start();<br />
}<br />
<br />
private void ReceiveData()<br />
{<br />
int recv;<br />
string datastr = "";<br />
while (true)<br />
{<br />
if (client.Connected)<br />
{<br />
cleardata();<br />
recv = client.Receive(data);<br />
datastr = Encoding.ASCII.GetString(data);<br />
if (datastr == "exit")<br />
break;<br />
AddLine(textBox1, datastr);<br />
}<br />
}<br />
client.Close();<br />
AddLine(textBox1, "Connection closed");<br />
return;<br />
}<br />
}<br />
If anyone knows how to make a TCP connection where the same client can connect and disconnect multiple times.
Please help me! Thanks.
Regards,
Marta Paniti
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
pmartike wrote: If anyone knows how to make a TCP connection where the same client can connect and disconnect multiple times.
Sure.
In your code above, you're only listening for the first connection. Your Listen_Button_Click() method calls BeginReceive() and passes it the delegate for AcceptConn() .
So far so good, but once that method is called your socket isn't listening anymore. You have to re-wire the callback by invoking BeginReceive() again to listen for more incoming connections.
Share and enjoy.
Sean
|
|
|
|
|
Thanks!
Problem solved
--------------------------------
visit: http://pmartike.deviantart.com/
|
|
|
|
|
Hi,
do you have any idea how to find the Width of a document ?
thanks.
|
|
|
|
|
Define "document" in the current context.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
define the context of the current "document"
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|