Home > Net >  C # the folder the file to the database in real time
C # the folder the file to the database in real time

Time:11-27

TXT file in folder is has been produced, how to achieve the real time read the files in the folder after wrote in the database? Then delete the original file and what's mentality, please help to a great god, thank you

CodePudding user response:

What is the TXT content? This will have a look at,

In general, XLS or CSV format, can be read through the SQL script to write directly, to plan work,

CodePudding user response:

A new FileSystemWatcher to monitor it.

Change in the thread pool to read readallline then insert..

CodePudding user response:

Can use Windows. The form. The timer timer? Will there be any problem?
Main purpose is to put the TXT files in the folder after reading written into the database, then delete the source file,
This is to have real time record in the database,

CodePudding user response:

Curious why you will never forget the timer, the second floor has told you the right way, don't tell me again super classes,
If you said what all super classes, so we need to reply to what he is not the super classes??

The timer?
How do you want to compare? List , seek difference set? O difference set super classes?
And then what? If the two files are generated again? What are you going to do? The queue? Queue super classes?
And then, in the delete, while in the queue? Thread? Thread the super classes?
If the thread again, that the list, queue to lock, do you want to use the security list, security queue? The super classes again?

Well, your own to define, exactly how to code, you just feel good for beginners, not super classes for beginners,

Never super classes, that is not always a novice

CodePudding user response:

Normal code

FileSystemWatcher
. Observation data sources ()
. Filtering produced only set ()//FileSystemWatcher likely repeat
Subscription (async filepath=& gt;

If (await filereadok)/read/waiting for the file, file is likely to take up, need to asynchronous block read
{
Await processing file ();
Await to delete file ()
}
)

Don't always reply with I am a novice, the novice is not equal to always marking time, if you can not accept these things, two years later it will be hard to have a foothold, to know the net core has completely changed the ecological environment, even cities such as wuhan, also begin to hire with the salary of 15 to 30 k recruitment neter, if still marking time, gap will be pulled back two years later, either 8 to 12 or 15-30. Don't shout and a bunch of people running here after is Microsoft to hurt me

CodePudding user response:

Us why say so, but a little bit expand your problem, you can find, this is the Java in this ten years to do, now.net core, so we also need to do these things

1. Compatible with the old system, a large number of real-time file data statistics -- -- -- -- -- -- -- -- the hadoop, hbase, MinIO FastDFS, spark, analysis and processing of real-time distributed file
2. The upgrade new system -- -- -- -- -- -- -- -- -- -- -- -- -- the MQTT, kafaka, ribitmq -- -- -- -- -- solution is what we want to be written to a file, why not write a public message system

CodePudding user response:

Thank you @ wanghui0380 mr.wong counsel, or appreciate, also thanks to the second floor, I use the timer is realized, don't know what is no problem, I according to the below FileSystemWatcher change ideas, feedback after test OK,
  •  Tags:  
  • C#
  • Related