|
When creating your StreamWriter, use a constructor[^] which takes a boolean 'append' parameter. Specify 'true' for this parameter.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
If you want to append this text to the very end of the file, then follow what Mike said. Otherwise, you'll have to read the file in, write the beginning of the file back out until you reach the point where you want to append your text, append your text, then continue writing out the rest of the .def file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello All,
I want to customize error messages returned by exceptions. For example I want to customize the following error
"Error [42000] [Microsoft] [Odbc SQL Server Driver] [SQL Server] could not find stored procedure"
I know I can restrict exception.message and throw a customized error, but how I will know whether the error is because of this..or something else...
Could anyone please let me know how can I do that in C#...
Thanks
Looney
|
|
|
|
|
hi
you have to write two catch Block to handle ODBC and other type of exception..
try<br />
{<br />
}<br />
catch(OdbcException odbc_ex)<br />
{<br />
for (int i=0; i < myException.Errors.Count; i++)<br />
{<br />
if (odbc_ex.Errors[i].NativeError == 42000)<br />
Console.WriteLine("Procedure not found...");<br />
else<br />
Console.WriteLine(odbc_ex.Errors[i].Message);<br />
}<br />
}<br />
catch(Exception ex)<br />
{<br />
}
Mihir...
|
|
|
|
|
Thanks a lot. I will follow what you have said.
|
|
|
|
|
Hi,
how do i export and import data to a database, thumbdrive, zipdrive etc.. (but first i got to create a database and i dono how to do dat)..
Thz a lot!
|
|
|
|
|
hello
plz tell me how to pass a specific index of the array to a function and how to recieve that what will be function call code and function declaration code.
like if i want to pass array [1] element. so wht will be the passing and receiving code.
thanks
|
|
|
|
|
void FunctionCaller()
{
string [] ArrStr = new string[]{"str1","str2","str3"};
int [] ArrInt = new int[]{1,2,3,4,5};
MyFunction(ArrStr[1]);
MyFunction(ArrInt[2]);
}
void MyFunction(object ArrElement)
{
Console.WriteLine(ArrElement);
}
may be helpful to you
Mihir...
|
|
|
|
|
Well, how would you: check if a string doesn't starts with a caracter.
I've gladly take tips on good string searching/manipulating classes. I'm wellknown of StringBuilder...
_____________________________
...and justice for all
APe
|
|
|
|
|
U means "string doesn't starts with a character" ?
If so,
if(!strName.StartsWith(ch))
Ammu
|
|
|
|
|
But I like to check if it starts with a or b or c or.....
Don't really like to do this:
if (str.StartsWith("a")...)....
if (str.StartsWith("b")...)....
if (str.StartsWith("c")...)....
if (str.StartsWith("d")...)....
if (str.StartsWith("e")...)....
_____________________________
...and justice for all
APe
|
|
|
|
|
private void txtFirstName_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
if(txtbox1.Text.Length == 0)
{
if (!Char.IsLetter(e.KeyChar))
e.Handled=true;
}
}
The above code in will check for each key press and will only allow characters...You can modify the code to ur advantage...
Looney
|
|
|
|
|
So u want to check whether the first character is alphabet or digit. Am I correct ????
Then,
char.IsLetter(str,0)
It will return true if the first character is a letter; otherwise false.
Ammu
Ammu
|
|
|
|
|
Hello,
Using C#, how can I read from a file which is used be another process? Something like Notepad opens a file which is used be another process.
Thank you in advance,
adosun
|
|
|
|
|
hi
i think it is not possible to access file which is accessed by the another process..you will get access violation exception while accessing this file.
...but in a case, you open a text file in any editor e.g Notepad, WordPad you can access file coz what editor does is it access file and append it in to the control and close it.
Mihir...
|
|
|
|
|
If the file is opened DenyShareRead by the host process, you can't open it until the host closes the file, period. There's no way around this.
By deault, the FileStream object opens a file with FileShare.Read permissions. That means that any other process can open the file for reading while you have the file open.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I ensure that only one copy of my application (C#) runs?
(In technical terms - it may mean one process or one thread or something else?)
Thanks
|
|
|
|
|
Don't you like to search here before ?
You can use mutex for it. There are a lot articles on the topic. Here is one of them [^].
Andrew
|
|
|
|
|
hi
do this
public static void Main()<br />
{<br />
<br />
System.Diagnostics.Process[] process = <br />
System.Diagnostics.Process.GetProcessesByName("YourAppName");<br />
<br />
if ( process.Length >= 2 )<br />
{<br />
MessageBox.Show("Application already running..");<br />
Appliction.End();<br />
}<br />
else<br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
}
Mihir...
|
|
|
|
|
Hi,
How to check the version of MSWord installed in the pc in C# ?
Any code samples ?
Thanks
|
|
|
|
|
I have a Win32 DLL that has a standard _stdcall (WINAPI) exports. I am able to call these fine from C#. One call in particular however has a callback to a CDECL function. How would I set that up? Following is the specific.
Win32 DLL Declaration for function in MyDLL.dll
extern "C" int WINAPI SpecialTimerFunction(int Val, int (*Callback)(int InVal))
C# Declaration
public class MyClass
{
public delegate int MyCallback(int InVal);
[DllImport("MyDLL.dll")]
public static extern int SpecialTimerFunction(int Val,MyCallback Callback);
}
How do I declare the delegate to ensure that the marshaller will understand that the callback is of type CDECL?
Thanks a million.
Berto
WCSC (Willies Computer Software Co)
http://www.wcscnet.com
|
|
|
|
|
Think RS232 wrote:
public delegate int MyCallback(int InVal);
This looks correct.
Define the import function as:
static extern int SpecialTimerFunction(int Val,IntPtr Callback);
When you are creating the delegate wrap it in a GCHandle (pinned). As follows:
GCHandle gch = new GCHandle(new MyCallback(foo), GCHandleType.Pinned);
int res = SpecialTimerFunction(bar, gch.AddressOfPinnedObject());
gch.Free();
xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots
|
|
|
|
|
|
|
Hello,
I'm trying to implement multiple sort in a ListView control (yes, it will come later to CP as an article) but I can't find out if the Ctrl key is pressed down when I get the ColumnClick event.
In Win32 there's GetKeyState , but what's the equivalent in .NET? Any ideas?
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|