C Loop Through Folder Files ImagesThe phrase iterate a directory tree means to access each file in each nested subdirectory under a specified root folder, to any depth. You do not necessarily have. I want to get the files in folder and also in its subfolders. The following code does not get the files in its subfolder string files Directory. GetFiles. Connecting to Oracle from C Winforms Asp. Summary. The other day, I needed to access an oracle database from a C console application, and google found a whole heap of different ways to achieve this. Heres the best way i found that works, and you dont even need to install any oracle software. Ive deliberately kept this entry short, to emphasise that this is the simple and straightforward way. Also, you may want to check out another post for a simple application using this technique Oracle Explorer very simple open source Toad alternative. Oracle bits Full credit This part uses details from http www. KBdatabaseCInstantOracle. Youll need the following files, which can be obtained from within the basic lite version of oracles instant client. In my case, i downloaded the instantclient basiclite win. Youll need to place these DLLs in the same folder as your applications. EXE. If youre using asp. Bin folder of your application. W3E07eyfSdo/U5hI6GYlOZI/AAAAAAAACaU/-HZRqIRZiuI/s1600/ForLoopContainer.jpg' alt='C# Loop Through Folder Files' title='C# Loop Through Folder Files' />The important thing to note is that you dont need to install the instant client, or register these DLLs or anything, just grab them from the zip file and ignore the rest of its contents. Visual Studio bits. Note that im using. Net 2, with Visual Studio 2. There may be differences in other versions, however im hoping for your sake that it is similar enough to figure out. In the solution explorer, right click on References and choose Add Reference. C Loop Through Folder Files GamesGh. El. Hlcf. Cwqluml. GHfis. Then scroll through the list until you find System. Data. Oracle. Client and click OK. EHb. BAb. Eswahink. Now for the code. Youll need this using at the top of your file. System. Data. Oracle. Client. Heres a simple function I wrote to create an oracle connection string, it may be useful to you. Oracle. Conn. Stringstring host,string port,string servicename,string user,string pass. String. Format. Data SourceDESCRIPTIONADDRESSPROTOCOLTCPHOST0. PORT1CONNECTDATASERVICENAME2 User Id3 Password4. And heres the gist of opening a connection, and reading all the lines. Youll notice the interface is pretty much the same as accessing SQL server. Oracle. Conn. Stringaaa,1. Oracle. Connection conn new Oracle. Connectionconnectionstring connect to oracle. Open open the oracle connection. Oracle. Command comm new Oracle. Commandsql, conn create the oracle sql command. Corel Draw Logo Design Tutorials Pdf. Oracle. Data. Reader rdr comm. Execute. Reader execute the oracle sql and start reading it. Read loop through each row from oracle. Console. Write. Line rdr0 You can do this. Console. Write. Line rdr. Get. String0 or this. Console. Write. Line rdrcolumnname or this. Close close the oracle reader. Close close the oracle connection. Copying from Oracle to Sql Server. Heres an example of copying a 2 column table from Oracle to Sql server. Lets pretend this table is called foo, and has two integer columns x and y. Copy. Oracle. To. Sql. string connectionstring Oracle. Conn. Stringhost,1. Oracle. Connection conn new Oracle. Connectionconnectionstring connect to oracle. Open open the oracle connection. Oracle. Command comm new Oracle. Commandsql, conn create the oracle sql command. Oracle. Data. Reader rdr comm. Execute. Reader execute the oracle sql and start reading it. Sql. Connection sqlconn new Sql. Connectionsqlconnstring connect to the sql 2. Open open the sql database. Read the data from oracle, and every 1. String. Builder sb new String. Builder build the insert statements with this. Read loop through each row from oracle. Append. Format. insert into foox,y values0,1. DB every 1. 00 rows. Sql. Command sqlcomm new Sql. Commandsb. To. String, sqlconn. Execute. Non. Query. String. Builder. DB. Length 0. Sql. Command sqlcomm new Sql. Commandsb. To. String, sqlconn. Execute. Non. Query. Close close the oracle reader. Close close the sql connection. Close close the oracle connection. Thanks for reading And if you want to get in touch, Id love to hear from you chris. Circle Of Fifths Software. SOLID Principles in CHi everybody. In this article I will cover the following topics. Reasons behind most of the unsuccessful application. Intro to SOLID principles. DIPReason behind most of the unsuccessful application. Developers start building applications with good and tidy designs using their knowledge and experience. But over time, applications might develop bugs. The application design must be altered for every change request or new feature request. After some time we might need to put in a lot of effort, even for simple tasks and it might require a full working knowledge of the entire system. But we cant blame change or new feature requests. They are part of the software development. We cant stop them and refuse them either. So who is the culprit here Obviously it is the design of the application. The following are the design flaws that cause the damage in software, mostly. Putting more stress on classes by assigning more responsibilities to them. A lot of functionality not related to a class. Forcing the classes to depend on each other. If classes are dependent on each other in other words tightly coupled, then a change in one will affect the other. Spreading duplicate code in the systemapplication. Solution. Choosing the correct architecture in other words MVC, 3 tier, Layered, MVP, MVVP and so on. Following Design Principles. Choosing correct Design Patterns to build the software based on its specifications. Now we go through the Design Principles first and will cover the rest soon. Intro to SOLID principles. SOLID principles are the design principles that enable us to manage with most of the software design problems. Robert C. Martin compiled these principles in the 1. These principles provide us ways to move from tightly coupled code and little encapsulation to the desired results of loosely coupled and encapsulated real needs of a business properly. SOLID is an acronym of the following. S Single Responsibility Principle SRPO Open closed Principle OSPL Liskov substitution Principle LSPI Interface Segregation Principle ISPD Dependency Inversion Principle DIPS Single Responsibility Principle SRP SRP says Every software module should have only one reason to change. This means that every class, or similar structure, in your code should have only one job to do. Everything in that class should be related to a single purpose. Our class should not be like a Swiss knife wherein if one of them needs to be changed then the entire tool needs to be altered. It does not mean that your classes should only contain one method or property. There may be many members as long as they relate to the single responsibility. The Single Responsibility Principle gives us a good way of identifying classes at the design phase of an application and it makes you think of all the ways a class can change. A good separation of responsibilities is done only when the full picture of how the application should work. Let us check this with an example. User. Service public void Registerstring email, string password if Validate. Emailemail throw new Validation. ExceptionEmail is not an email var user new Useremail, password Send. Emailnew Mail. Messagemysitenowhere. SubjectHEllo foo public virtual bool Validate. Emailstring email return email. Contains public bool Send. EmailMail. Message message smtp. Client. Sendmessage It looks fine, but it is not following SRP. The Send. Email and Validate. Email methods have nothing to do within the User. Service class. Lets refract it. User. Service Email. Service email. Service Db. Context db. Context public User. ServiceEmail. Service a. Email. Service, Db. Context a. Db. Context email. Service a. Email. Service db. Context a. Db. Context public void Registerstring email, string password if email. Service. Validate. Emailemail throw new Validation. ExceptionEmail is not an email var user new Useremail, password db. Context. Saveuser email. Service. Send. Emailnew Mail. Messagemynamemydomain. SubjectHi. How are you public class Email. Service Smtp. Client smtp. Client public Email. ServiceSmtp. Client a. Smtp. Client smtp. Client a. Smtp. Client public bool virtual Validate. Emailstring email return email. Contains public bool Send. EmailMail. Message message smtp. Client. Sendmessage O OpenClosed Principle. The Openclosed Principle says A software moduleclass is open for extension and closed for modification. Here Open for extension means, we need to design our moduleclass in such a way that the new functionality can be added only when new requirements are generated. Closed for modification means we have already developed a class and it has gone through unit testing. We should then not alter it until we find bugs. As it says, a class should be open for extensions, we can use inheritance to do this. Okay, lets dive into an example. Suppose we have a Rectangle class with the properties Height and Width. Rectangle public double Height get set public double Wight get set Our app needs the ability to calculate the total area of a collection of Rectangles. Since we already learned the Single Responsibility Principle SRP, we dont need to put the total area calculation code inside the rectangle. So here I created another class for area calculation. Area. Calculator public double Total. AreaRectangle arr. Rectangles double area foreachvar obj. Rectangle in arr. Rectangles area obj. Rectangle. Height obj. Rectangle. Width return area Hey, we did it. We made our app without violating SRP. No issues for now. But can we extend our app so that it could calculate the area of not only Rectangles but also the area of Circles as wellNow we have an issue with the area calculation issue, because the way to do circle area calculation is different. Hmm. Not a big deal. We can change the Total. Area method a bit, so that it can accept an array of objects as an argument. We check the object type in the loop and do area calculation based on the object type. Rectangle public double Height get set public double Wight get set public class Circle public double Radius get set public class Area. Calculator public double Total. Areaobject arr. Objects double area 0 Rectangle obj. Rectangle Circle obj. Circle foreachvar obj in arr. Objects ifobj is Rectangle obj. Rectangle Rectangleobj area obj. Height obj. Width else obj. Circle Circleobj area obj. Circle. Radius obj. Circle. Radius Math. PI return area Wow. We are done with the change. Here we successfully introduced Circle into our app. We can add a Triangle and calculate its area by adding one more if block in the Total. Area method of Area. Calculator. But every time we introduce a new shape we need to alter the Total. Area method. So the Area. Calculator class is not closed for modification.