|
Hello
1- Use Form.ShowDialog() , and you can get DialogResult as the return value.
2- If you mean by "under" that the second form appears behind the MDIParent, use Form.BringToFornt() . otherwise, please elaborate.
3- Search the articles[^].
Regards
|
|
|
|
|
Really, thanks a lot (Andrew & Nader ).
|
|
|
|
|
Having done a search both here and google I have found a ton of information about using HttpPostedFile. I have a situation where users will be uploading drawing files. Most of the time these files will not be very large, there are however those few people that continue to use Solidworks and create files that are 100Mb and up. Now I would just increase the max Http Request length but considering that I could have several people trying to upload huge files at the same time...this could get me in trouble.
I am not sure what to do...I am not able to use any 3rd party plugins or activeX controls...
Any ideas would be great....
Thanks,
Will
I hate users. Not all of them, just the ones who talk.CP member: Al Einstien
|
|
|
|
|
Hello
AFAIK the best practice in transfering a file over a network is making it in chunks. This would give you two advantages:
1- Minimize data loss, and improve recovery.
2- Allows the user to resume uploading/downloading files later if there is a connection failure.
I wouldn't like it if I lose my 99Mb upload for a 2 secoinds power failure.;P
Regards
|
|
|
|
|
hi guys,
this question related to my previous post:
Link
The current problem is redirecting the output to a textbox...
there is the issue of a thread different from form's thread, trying to access the textbox.text property (i've read an article in msdn, i which they query the invokerequired property of the textbox and invoke it same method using this.invoke, but it doesn't seem to solve the problem)
again, i want to start a new process and redirect its output to a textbox at runtime (every line of text written by the process should be written at runtime at the textbox, without waiting for the process to finish)...
the answer in the first reply i got helped, but i couldn't make it thread safe (and in the buttom line i think it wrote the output to the textbox, but the window couldn't refresh itself until the other process has finished...
any suggestions?
Thanks in advance,
Erik.
|
|
|
|
|
Hello
Your problem -I presume- is that your thread waits for the process to finish until it views the output in the textbox? You should use Process.BeginOutputReadLine() method, and it should work fine. If you are using it, what seems to be the problem again?
About the Invoke() , it should also work fine if you use the Process.BeginOutputReadLine() method. If you still can't get it right post your code and maybe we could work it out.
Regards
|
|
|
|
|
you are familiar to "..." block same as my first reply
...
System.Diagnostics.Process pr = new System.Diagnostics.Process();
pr.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
pr.StartInfo.FileName = "cmd.exe";
pr.StartInfo.UseShellExecute = false;
pr.StartInfo.RedirectStandardInput = true;
pr.StartInfo.RedirectStandardOutput = true;
pr.Start();
pr.OutputDataReceived += new System.Diagnostics.DataReceivedEventHandler(pr_OutputDataReceived);
pr.BeginOutputReadLine();
System.IO.StreamWriter swWriter = pr.StandardInput;
swWriter.WriteLine("echo SomeTextHere\n");
swWriter.Flush();
...
//Define a delagate function
delegate void SetTextCallback(string text);
//Define a function for setting
void SetText(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
void pr_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
//event fired and u have data use it thread-safe
SetText(e.Data);
}
if this does not work define your problem with more details
UMS
|
|
|
|
|
Thanks for the replies guys, umseker thats almost exacly what i wrote...
the problem is that the window doesn't repaint itself until the other process has finished (i presume).
Anyway i'll post the code when i'll get home...
Erik.
|
|
|
|
|
Consider the code
DataTable dt = /* something */
double h_bid = (double)dt.Row[(int)SecurityColumns.BID];
double h_offer = (double)dt.Row[(int)SecurityColumns.ASK];
where /SecurityColumns.BID/ and /.ASK/ come from the enum type /SecurityColumns/.
Does the compiler determine before runtime the integer values of .BID and .ASK and make the substitution into the binaries? Or is the enum eval'd at runtime and converted to an int?
Execution speed is what I'm after. Thanks.
|
|
|
|
|
As the values of the enum is known at compile time, the values will be evaluated when it's compiled.
The compiler always evaluates everything that it can. For an example:
string msg = "Hello" + " " + "world!";
produces the exact same code as:
string msg = "Hello world!";
---
b { font-weight: normal; }
|
|
|
|
|
|
i am working with icodecompiler
ICodeCompiler compiler = codeProvider.CreateCompiler();
CompilerParameters parameters = new CompilerParameters();
it works well when i give it a cs form containing main function in it
but i want to build a form in which there is no main what should i do to achieve this
is it possible to do this without main if no then is there some way to add main at run time if the main is not there as in my case
|
|
|
|
|
Assalam-o-Alaikum,
i've compiled a classLibrary to generate a DLL. as you know classLibrary doesnt have a main method,
i used a switch "/target:library".
parameters.CompilerOptions="/target:library";
there is also a method named MainClass in CompilerParameters class, i didnt use that but i think u can specify ur main class in it.
I hope this will help you
Allah Hafiz
-- modified at 4:29 Tuesday 3rd October, 2006
|
|
|
|
|
im working on a P2P messaging and file sharing app with C#. i want to use HTTP between peers in case the packets might be dropped by firewalls.
how can i do this?
wht technologies should i use?
thanks...
asamay
|
|
|
|
|
You could emulate a very simple Web server.
Use a TcpListener to listen on Port 80 and handle some very basic HTTP requests.
On the client side you can use a HttpWebRequest do send/read the data you need.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thank you so much!!
it looks easy to do!
asamay
|
|
|
|
|
I am trying to encrypt and decrypt using the functions below. Encryption is successful but decryption will return Bad Data. The Utils.byteToHexStr is a function to convert a hexadecimal string into a byte array where by each two characters of the hexadecimal string are combined to create one byte. (eg. 0x31 0x32 0x33 0x34 (ASCII 1234) -> 0x12 0x34). This is the requirement of the inputdata for encryption and decryption.
crypto.DesEncrypt("1234567812345678", "123456789012345678901234567890123456789012345678", "0000000000000000");
- > the code above got 0x2D 0xC8 0x88 0xCA 0x7D 0x62 0x17 0xE7 as result. However, to restore the original value using the code below, the program complain "Bad Data". I have tried all sorts of ways but still to no avail. Please provide me some advices.
crypto.DesDecrypt("2DC888CA7D6217E7", "123456789012345678901234567890123456789012345678", "0000000000000000");
public static byte[] DesEncrypt(string stringToEncrypt, string szKey, string szIV)
{
byte[] data = Utils.byteToHexStr(stringToEncrypt);
byte[] m_bDESKey = Utils.byteToHexStr(szKey);
byte[] m_bDESIV = Utils.byteToHexStr(szIV);
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.Mode = CipherMode.ECB;
MemoryStream ms = new MemoryStream(4096);
CryptoStream encStream = new CryptoStream(ms,des.CreateEncryptor(m_bDESKey, m_bDESIV),CryptoStreamMode.Write);
encStream.Write(data,0,data.Length);
//encStream.FlushFinalBlock();
//calculate the length of the encrypted data
byte[] bResult = new byte[ms.Position];
ms.Position = 0;
ms.Read(bResult, 0, bResult.Length) ;
encStream.Close();
return bResult;
}
public static string DesDecrypt(string stringToDeCrypt, string szKey, string szIV)
{
byte[] data = Utils.byteToHexStr(stringToDeCrypt);
byte[] m_bDESKey = Utils.byteToHexStr(szKey);
byte[] m_bDESIV = Utils.byteToHexStr(szIV);
TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();
des.Mode = CipherMode.ECB;
MemoryStream ms = new MemoryStream(4096);
CryptoStream encStream = new CryptoStream(ms,des.CreateDecryptor(m_bDESKey, m_bDESIV),CryptoStreamMode.Read);
ms.Write(data,0,data.Length);
ms.Position = 0;
string strResult = new StreamReader(encStream).ReadToEnd();
encStream.Close();
return strResult;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public static byte[] byteToHexStr(string szHexString)
{
int discarded;
byte[] byteArray = HexEncoding.GetBytes(szHexString, out discarded);
if (discarded > 0)
{
return null;
}
return byteArray;
}
public static byte[] GetBytes(string hexString, out int discarded)
{
discarded = 0;
string newString = "";
char c;
// remove all none A-F, 0-9, characters
for (int i=0; i<hexstring.length; i++)
="" {
="" c="hexString[i];
" if="" (ishexdigit(c))
="" newstring="" +="c;
" else
="" discarded++;
="" }
="" odd="" number="" of="" characters,="" discard="" last="" character
="" (newstring.length="" %="" 2="" !="0)
" newstring.length-1);
="" }
="" int="" bytelength="newString.Length" 2;
="" byte[]="" bytes="new" byte[bytelength];
="" string="" hex;
="" j="0;
" for="" (int="" i="0;" i<bytes.length;="" hex="new" string(new="" char[]="" {newstring[j],="" newstring[j+1]});
="" bytes[i]="HexToByte(hex);
" return="" bytes;
="" public="" static="" tostring(byte[]="" bytes)
="" hexstring="" ;
="" hexstring;
="" <summary="">
/// Determines if given string is in proper hexadecimal string format
///
/// <param name="hexString" />
/// <returns>
public static bool InHexFormat(string hexString)
{
bool hexFormat = true;
foreach (char digit in hexString)
{
if (!IsHexDigit(digit))
{
hexFormat = false;
break;
}
}
return hexFormat;
}
///
/// Returns true is c is a hexadecimal digit (A-F, a-f, 0-9)
///
/// <param name="c" />Character to test
/// <returns>true if hex digit, false if not
public static bool IsHexDigit(Char c)
{
int numChar;
int numA = Convert.ToInt32('A');
int num1 = Convert.ToInt32('0');
c = Char.ToUpper(c);
numChar = Convert.ToInt32(c);
if (numChar >= numA && numChar < (numA + 6))
return true;
if (numChar >= num1 && numChar < (num1 + 10))
return true;
return false;
}
///
/// Converts 1 or 2 character string into equivalant byte value
///
/// <param name="hex" />1 or 2 character string
/// <returns>byte
private static byte HexToByte(string hex)
{
if (hex.Length > 2 || hex.Length <= 0)
throw new ArgumentException("hex must be 1 or 2 characters in length");
byte newByte = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber);
return newByte;
}
|
|
|
|
|
i have a listbox and i want to put the list items (just the text) shown in an excel sheet.
how can i achieve this using `ctrl + c`, `crtl + v`? how can i catch the ctrl + c keypress event and have access to windows transfer area in .NET?
thanks in advance
|
|
|
|
|
What you would do is hook into the KeyPress event. The event arguments pass the key information.
|
|
|
|
|
Does anyone know the status with NDoc?
Obviously I've read their webpage and it looks like activity is slow or dead. I've tried NDoc 1.3 against VS2005 and it doesn't work. Its such an awesome application I hate to see it go stale.
|
|
|
|
|
It's dead. It was announced a few weeks ago by the NDoc founder. Microsoft started a new project, SandCastle[^], to replace the now-dead NDoc.
|
|
|
|
|
Right on!
|
|
|
|
|
Well, thanks for a definite answer, although its sad indeed. Just downloaded Sandcastle... there's no front end like NDoc? Has anyone actually used this tool?
|
|
|
|
|
AFAIK it's working and was used by Microsoft to build framework documentation. Take a look at the following article which allows you to keep the look and feel of NDoc while working with Sandcastle. Sandcastle Builder.asp[^]
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Our posts crossed. Okay, great link. I'll have a look. Thanks!
|
|
|
|