|
I am relatively new to the C# language and need to extract data from a text file. I would like to be able to search the file which is tab delimmited and extract various fields. I have been using StreamReader to read the file but I am not sure of the method that actually searches for relevant fields and then extracts them.
|
|
|
|
|
Are you looking specifically on ways to parse the data once you have read it from the file? Specifically you could look into using regular expressions within .NET as a parsing mechanism. Check out the documentation .NET Framework Regular Expressions[^] from .NET Framework Developer's Guide.
|
|
|
|
|
Thankyou, I will have a read of the documentation. I basically have a text file full of results in rows and columns. The idea is that the user selects the results that need to be viewed and they are extracted from the file.
|
|
|
|
|
You could always use ADO.
Heres an example in VB.Net that I found usefull:
http://www.dotnetspider.com/technology/KBPages/890.aspx[^]
It allows sql queries to be performed against the csv file. You can even perform joins to other csv files in the same directory.
I believe you will have to create a Schema.ini file if you file is tab delimited.
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
Hi,
I am trying to create an enhanced metafile that draws several retangles. I want the rectangles to have physical dimensions in mm, so that they will be cut by a laser engraver in these units. The code below attempts to create an EMF with a single rectange 100mm by 100mm, but when I open it in Corel Draw, it says the rectangle is only 94.5mm by 88.6mm. Can anyone explain this disparity to me?
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
// Create temporary Graphics object for metafile
// creation and get handle to its device context.
Graphics newGraphics = this.CreateGraphics();
IntPtr hdc = newGraphics.GetHdc();
// Create metafile object to record.
Metafile metaFile1 = new Metafile("SampMeta.emf", hdc);
// Create graphics object to record metaFile.
Graphics metaGraphics = Graphics.FromImage(metaFile1);
//Set the graphics unit to mm
metaGraphics.PageUnit = GraphicsUnit.Millimeter;
// Draw rectangle in metaFile.
metaGraphics.DrawRectangle(new Pen(Color.Black, 5), 0, 0, 100, 100);
// Create comment and add to metaFile.
byte[] metaComment = {(byte)'T', (byte)'e', (byte)'s', (byte)'t'};
metaGraphics.AddMetafileComment(metaComment);
// Dispose of graphics object.
metaGraphics.Dispose();
// Dispose of metafile.
metaFile1.Dispose();
// Release handle to temporary device context.
newGraphics.ReleaseHdc(hdc);
// Dispose of scratch graphics object.
newGraphics.Dispose();
}
J Adam Crain
UNC-CH Department of Physics and Astronomy
crain@physics.unc.edu
|
|
|
|
|
is it possible to separate each for separatly to avoid sending the whole application each time to the customer whe I update just a simple text in one form?
how?
many thanks....
Jassim Rahma
|
|
|
|
|
jrahma wrote:
is it possible to separate each for separatly to avoid sending the whole application each time to the customer whe I update just a simple text in one form?
Yes, you could feasibly build each individual form into their own assembly, however you could also consider using the localization support in .NET and keep that as a separate assembly, thus allowing you to simply distribute that alone. If you are interested in checking out the localization support for .NET I would recommend you read Resources and Localization Using the .NET Framework SDK[^] and Resources in Applications[^] from the .NET Framework tutorial and developers guide.
|
|
|
|
|
Now I am stumped! I have worked out how to talk to an ASCII printer over a COM port (using system APIs), but how do I talk to an ASCII printer that is hanging on an USB port?
Assuming somebody has an elegant answer to this, will this also work for .NET Compact Framework?
Peter Beedell
"Remember that age and treachery will always triumph over youth and ability." Quoted from the BBC Comedy 'The Office'.
|
|
|
|
|
You'll need a .DLL to handle communication with the USB printer for your app. There is no ".NET way" of doing this.
Try searching the web for "Raw USB printer" or something like that, or, if your proficient with C++ and writing lower level USB device drivers, you can try writing it yourself.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I am writing a debugger and I am trying to implement a multi column TreeView for showing the local variabls (such as in visual .Net).
How can I implement it or maybe such implementation already exists as open source?
|
|
|
|
|
Have a look at:
http://www.codeproject.com/cs/miscctrl/treelistview.asp
|
|
|
|
|
I've got an ASP.NET application written in C# which uses an Access database. Sometimes, when several users try to access the application at the same time, a "file is opened exclusively by another user" exception is thrown.
AFAIK, I need to synchronize access to the database. I've got a single place where all database access (like read a dataset, executenonquery) methods are. I tried using a ManualResetEvent to perform the task, but the problem is still there.
Can anyone recommend an approach?
Regards,
Serge
my blog on Easy Projects .NET and object-relational mapping
|
|
|
|
|
To handle multiple users, the Jet database engine has to be able to create a .ldb file (i.e. if your database is called MyDatabase.mdb, it has to create MyDatabase.ldb). Check that the user account your ASP.NET process runs under can create files in the same directory as the .mdb. If Windows 2000 or XP, by default it's ASPNET, while on Windows Server 2003 it's NETWORK SERVICE.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Thank you very much, Mike! I thought it was a sync problem
Regards,
Serge
my blog on Easy Projects .NET and object-relational mapping
|
|
|
|
|
I've got the following problem: I have a DLL written in C++, that exports a function. That function basically puts a very simple CDialog object on the screen (either modal or unmodal).
I have a very simple forms-based C# program that uses this DLL to call the exported function. Everything works OK.
Now, I add a custom control in the CDIalog-derived class, in C++, using an OCX that was developed by another company. When having this OCX, the C# code calls the exported function, but the dialog is not shown.
If needed, I can provide the code.
Any ideas why I have this problem?
|
|
|
|
|
gabnicu wrote:
If needed, I can provide the code.
Please include a sample of the code. Also, have you tried to invoke this exported function from something like an MFC application?
|
|
|
|
|
How do I create a database application using C#?
I would like to display my database which is Microsoft Access .mdb in C#.
Meaning my database content should be displayed in the box of C#.
I am totally clueless about this.
Please Help.
Thanks.
|
|
|
|
|
|
mucho thanks. I shall try to look at it and try to UNDERSTAND it.
|
|
|
|
|
guys...everyone who replied and gave me advice thanks a lot! becuase it works!
one more teeny little thing now...
i want to do the same thing using databases in c# but now instead of an access file, connect it to an excel file.
Any tips?
Much appreciated!
|
|
|
|
|
Syasya Mortensen wrote:
How do I create a database application using C#?
I would highly recommend the documentation regarding ADO.NET located on MSDN. A good start is: Overview of ADO.NET[^] from the .NET Framework Developer's Guide. If you have further questions please feel free to post.
|
|
|
|
|
thank you very much. I shall read it and try to understand and comprehend it. Ill definitely post if i have any more questions.
|
|
|
|
|
hi thanks for your help. I have some other questions. I would like to do the same thing but now instead of an Access database, id like to do with an Excel speadsheet document. any tips?
thanks
|
|
|
|
|
if I have two form, form main contain progress bar, form2 has a Cal() method. If I want to call Cal() that Cal method is activate progress bar. please show me a simple code. thank you
|
|
|
|
|
Who calls the Cal method; your main form or form2?
How are both forms related to each other? Is your main form the parent of form2/ has it a reference to form2?
www.troschuetz.de
|
|
|
|