|
You're welcome!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Umm Griff, do you know of a good string builder reference as I can create the string save the string like I could with a string, how can I search the string to find the last item added to it and if its the same don't append it?
Further reading has revealed the .Remove method, however I am not sure this would work as you have to know the exact location in the string, however if you placed a test loop after each function that talked to the string something like
int i=0;
foreach(string subString in sbResults(',')
i++
if( i >4)
{
MessageBox.Show("extra!");
sbResults.Remove(i,5);
} if the message was 5 long. Am I on to anything here??
modified 10-Mar-16 11:11am.
|
|
|
|
|
StringBuilders don't have Contains, StartsWith, or EndsWith methods - so basically you can't search one.
What are you actually building up? Is this a single line of CSV data, or a file full, or what?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Sorry looks like you replied as I was updating my earlier response, I cannot type today for some reason. Its a single line of a CSV, some times the data can get duplicated via a switch...
|
|
|
|
|
I'd be tempted to say "sod that" and cheat!
Is the order important?
If not, then create a List<String> of elements to make up your CSV data, and use the Linq Method .Distinct to remove duplicates. Then String.Join to bolt 'em together with commas.
string csv = string.Join("," myList.Distinct());
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
The order is not really important, I am starting the record process from scratch. Thanks I will give it a look.
|
|
|
|
|
If threads are causing your duplicate, you're in even bigger trouble, since you are also accessing a Control property, something only the GUI thread is allowed to do.
IMO your code needs a big overhaul: use a model that holds your data, a view that takes care of the UI, and a separate object (or at least an explicit method) to create the output file(s) you need.
By not mixing it all up you'll avoid both illegal cross-thread Control accesses and the risk of duplicates in your CSV.
|
|
|
|
|
Thanks, I will give a look!
|
|
|
|
|
I would more likely keep a Dictionary or something to hold the items to be written, you can add an item more than once and it'll just overwrite the existing value, then format and write it once everything is ready.
A small class could easily be written to encapsulate Add, Write, Clear functions.
|
|
|
|
|
I'll look into that! Thanks
|
|
|
|
|
Hi.
Lemme try to be clear here.
I've a code, with two files: Form1.cs and Classes.cs
Classes.cs contains all my methods, variables, etc (and the FilesystemWatcher implementation).
Form1.cs (The main form) contains some button calls, and a call to FilesystemWatcher (when the button is pressed).
What i'm trying to accomplish and can't see to figure out is: Show a ProgressBar from this FilesystemWatcher.
Consider the following scenario: I Just clicked a button and FilesystemWatcher has started. It will monitor the folder and do operations over created files. How i'm gonna show the progress for that ?
On my readfiles() method (inside the Classes.cs) i've tought about passing a variable trough parameter that indicates how much of the file has been read - for so i would have to implement FilesystemWatcher in the Form1.cs. But the FilesystemWatcher calls all my methods.
His method on Classes.cs looks like:
SetupFileWatcher()
all other methods to convert files, etc...
Even if i move FilesystemWatcher to Form1 main code, he doesn't return any progress value - he just run methods as soon files are added.
Lemme try to show a piece of code (This happens at Classes.cs)
Implementing filesystem watcher on this method...
protected FileSystemWatcher SetupFileWatcher(string path)
FileSystemWatcher Call
public void ProgramProcessing(string filePath)
{
SetupFileWatcher(SelectedFolder);
InputFolderSelect();
ReadFiles();
FileDefinition();
ColorExtraction();
ColorValueExtraction();
DataGrouping();
NumberProcessing();
ColorPoolManipulation();
WriteInkzoneXML();
WriteColorPoolXML();
}
Now, this happens inside Form1.cs:
private void btnGo_Click_1(object sender, EventArgs e)
prg.ProgramProcessing(textBox1.Text);
How could i possibly achieve that ? Is it possible ? Al i would like is to show the progress for the operation (or at least the methods for reading files and write XML).
Thanks in advance for any help\guidance.
|
|
|
|
|
|
Message Removed
modified 8-Mar-16 4:20am.
|
|
|
|
|
Hi All,
I am trying to write console application using C# which can export IBM DB2 table data from master database and import same to IBM DB2 table in target database , provided both tables are not coming under same DB2 instance.
can someone please provide direction how to achieve this ?
I tried using DB2BulkCopy Class but not succeeded.
pls help
Thanks
|
|
|
|
|
|
Or you can hit it with a hammer - make a connection to DB1, query the data and store it somewhere.
Connect to DB2 and write each record into the target table from the temp store.
Definitely not elegant and may be unworkable with serious volume.
Explore setting up a linked server and creating a stored proc that can do the job without taking the data into your c# client.
There should also be the equivalent of SQL Servers DTS ETL tools!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for reply,
One more POC i am planning to write using SSIS package. Only one thing i need to check support of IBM DB2 with SSIS package.
|
|
|
|
|
i need to code windows form project to alert Earth quakes. This is i use web site. its update live earth quakes in world. No i need to get that details(Earth quake value) and active a alarm or message. so i need to read that values of this site. How can i do.. can anybody help me.. thank you..
|
|
|
|
|
Probably the easiest way for you to do this would be for your windows application to loop around and check to see if there are any new events. You would have to do this on a background thread.
This space for rent
|
|
|
|
|
Just to add to what Pete says, you also need to look at site scraping to extract teh data you are interested in.
A simple google should help with that: site scraping c# - Google Search[^]
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I am learning C# or others...
Can anybody tell me. WHere can i download the source code that is writen in the book that I have.
For example the book
1. Pro C# 5.0 and the .NET 4.5 Framework
or
2. Beginning Csharp Object-Oriented Programming 2nd Edition
|
|
|
|
|
When I google Beginning Csharp Object-Oriented Programming 2nd Edition one of the top results tells me where the source code is made available; and I expect so does the books preface.
If you want to become a programmer, you'll need some initiative and creativity...
|
|
|
|
|
Good point, well made
|
|
|
|
|
Luc Pattyn wrote: If you want to become a programmer, you'll need some initiative and creativity...
Well said
Vote up or Mark as Answered, if this information helped you.
Kind Regards - Kunal Chowdhury, Windows Platform Development MVP
|
|
|
|
|
Some book very difficult to find the code sample (that is used in the book).The code come with the CD Rom.But someone have lost it.Now he give me only the book.Not sample code.
|
|
|
|