|
Yes, you can do it that way also. When the file changes, you just have to know what lines are already written to console and write the new ones. Hopefully the FileSystemWatcher doesn't miss modifications if you're reading the file and it's modified at the same time. Also make sure that you don't lock the file while reading so that the listener is unable to write to it.
|
|
|
|
|
|
Member 2324483 wrote: am i on right track?
I don't think so. If you need the trace statements displayed in the command window, why to write it to a file and watch it? TextWriterTraceListener class has a constructor overload which takes TextWriter type. To output the trace to command window, follow the below steps.
1 - Goto project properties and change your project type to console application. This will start a command window with your form.
2 - Add the following code in the main .
static void Main() {
TextWriterTraceListener listener = new TextWriterTraceListener(Console.Out);
Trace.Listeners.Add(listener);
Application.Run(new YourStartupForm());
} You can see the Trace.WriteLine is writting to the command window.
|
|
|
|
|
Actually, i don't want to change my project type to console application. Its a product and i want to show trace output in separate window when it is enabled.
|
|
|
|
|
Hey,
im currently developing an application, one of the features of the app is that it creates
pdf files, but i want the files to be saved in a sub directory of where the application is
installed, but how do i code that?
thanks
|
|
|
|
|
You can use System.Reflection.Assembly.GetExecutingAssembly().Location . Just remove the application name part to get the directory portion and then add the subfolder you need.
|
|
|
|
|
Hallo - i hope somebody can help me....
i want to call a c-function with this code:
struct StrBox
{
char str[30];
};
struct StructBox
{
StrBox * box;
};
DLLIMPORT char * TestStrBox(StructBox *sb);
i used this c#-code to call it:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
struct StrBox
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string str;
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
struct StructBox
{
[MarshalAs(UnmanagedType.LPStruct)]
public StrBox box;
};
...
StructBox b = new StructBox();
b.box.str = "Hallo Welt!!!";
string str = TestStrBox(b);
but if execute it, i get:
Ausnahme System.TypeLoadException wurde im ausgeführten Programm ausgelöst:
Cannot marshal field 'box' of type 'marshal.StructBox': Invalid managed/unmanaged type combination (this value type must be paired with Struct).
So i think it have a problem, with the struct in the struct... but the struct HAVE to be in the struct
(this is just a test, who reflects a real issue).
Hope... somebody have an idea.
Sooo. Many thx in advance
|
|
|
|
|
Hi,
your C# code has a struct in a struct, your C++ code has a struct pointer in a struct.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Aahhh... ok!!
But how can i declare it in c#, that it is handled like a Pointer to a struct (is IntPtr the right way?)
|
|
|
|
|
Hi,
if the only thing you want to happen is passing a pointer, then IntPtr is the right type.
but that will not marshal the object pointed to, since IntPtr does not carry type information for you. You will have to explicitly marshal using Marshal.PtrToStructure() somehow.
I always try and avoid those complex marshal jobs. When both sides are mine, passing data is
implemented for minimal complexity, that's the only way I know to avoid everything getting copied
across the managed/unmanaged border.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:55 AM
|
|
|
|
|
Hello folks.
I have a quick question, so here it is: can I restart a form back to it's original state as if it was newly opened without referencing a parent form or closing it? If so, how?
Thanks dudes and dudettes!
|
|
|
|
|
Never tried it, but perhaps if you:
- set this.components = null
- remove all controls from this.Controls
- call InitializeComponent
|
|
|
|
|
Holy crockpot!
It works:
components = null;
Controls.Clear();
InitializeComponent();
Are you some kind of suprogrammer?
Thanks, Mika!
|
|
|
|
|
Lodeclaw wrote: Are you some kind of suprogrammer
Now I have to ask a stupid question: What's a subprogrammer?
Lodeclaw wrote: Thanks, Mika
You're welcome
|
|
|
|
|
Not subprogrammer. Don't make me explain my terrible pun.
|
|
|
|
|
Ah, I misread it
|
|
|
|
|
I am working on a project to design database system of a library using oracle as backhand and c# as forehand but i don't know commands to connect
c# form with oracle database.
kindly send me command lines.
|
|
|
|
|
Read this[^]
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
LMAO, how did you ever find the same link as me, it took me so long to actual get a google result for what the OP wanted - I guess thats why they always turn to CP lol
|
|
|
|
|
musefan wrote: I guess thats why they always turn to CP lol
Well, The good thing is that he wasn't asking for the source codez and it wasn't urgent. So I just asked him to read that article. Did I do something wrong?
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
No, I was just making a comment on how easy it is to find a search result that fits thier needs, yet they never seem to try for themselves
|
|
|
|
|
|
It depends on the technology you are using to connect. Are you using ODP.NET or ODBC for instance? If ODP, you'd create instances of OracleConnection and OracleCommand objects. Your connection string would be based on the entry in TNSNAMES.ORA that you are aiming to connect to. So, suppose the SID was MYORA, then your connection string might look like this "Data Source=MyOra; User ID=NamedUser; Password=Password;"
|
|
|
|
|
Hi all,
I am looking for MCTS[70-536,70-526,70-528] papers....where should i get this content
pages...if you people have anything this info please post a link or you may post info to my mail and one more actually am a c# developer so is there any chances to get vb.net questions above mentioned papers please let me know this info very urgent ...........
thank you in advance.....
|
|
|
|
|