I want to compare files of two folders in vb.net with respect of date time and size and put the odd ones in two list boxes for each folder. I am not getting through the logic. Can any one of you help me with logic or code?
Thank you.
Get the FileInfo for each file in each of the directories.
Compare the required properties of each.
Consider what to do if there are files in one directory which are not in the other.
Question scope is too wide to be covered on StackOverflow.
However, there is an open source project called DirComp.NET.
It looks like a good starting point for you.
DirComp.NET is a simple command-line tool written in VB.NET, which compares two directories, and either lists differences or mirrors one directory onto another. For example, it can be used to backup large file repository by maintaining a mirror copy. It lives well with existing Windows infrastructure, which already provides file shares. And finally, DirComp.NET is based on .NET Framework 2.0, which is available from Windows 2000 and up.
Related
Background: I am working with Angular (but my problem is not particular to any language or framework). In Angular, each component requires four separate files. So, we often find ourselves with 40+ files open. But, most of these files can be tiny, less than 20 lines each.
Many IDEs allow you to open your files in multiple windows. Each window can have a different panel, and each panel can have different tabs. This is great, but honestly, still isn't enough.
What I want: In addition to windows, panels, and tabs, I'd like to add another level of organization.
I speculate this has probably existed for decades, but I just don't know what it's called. At the very least, I speculate this has existed at least since Angular was a thing.
For example, here is a screenshot of VSCode with four files open across four panels. (Code taken from Angular dynamic component tutorial):
And here is a quick mockup showing what I'm looking for. Four files are open, but the three shortest ones are "concatenated" into one editor. Arrow-key down from the bottom of one file will bring you to the first line of the next file.
Notably, these files are not actually concatenated on-disk.
TLDR: What text editor can allow me to edit multiple files as if they were concatenated, as in the mockup above?
If the files stay as separate windows/tabs, the file editor would have to shrink each tab to a minimal height, and then tile them vertically. If any editor can do it, I suspect it would be emacs or vim. You might also be able to do it by opening separate editor windows and using a tiling window manager.
We can achieve a similar effect with some text editing magic. It would be something like:
Add a header to each file consisting of a unique separator (e.g. # === magic separator === filename my_file.js ===)
Use cat to combine all the files into one file
Edit this one file
When done, use the separator to break them up and put the text back into the original files
You could easily write some scripts for combining and splitting so you can do it quickly. You can also set up a background script that automatically runs the splitter as you edit the combined file. However, the combined file would essentially be a new file, so you could not view changes on it with git, and VS Code's CodeLens/Inline blame wouldn't work.
One option would be to develop your codebase with the combined files checked in to VCS, and then only have the splitter script as part of your "build" step. So you would make your changes, run ./build.sh which splits the files into some temp directory, and then run your application from there.
Lastly, and I hate to be snide, but the fact is that this problem is best solved by avoiding poorly designed frameworks that do not consider developer ergonomics. Many other languages give the developer much freedom and many tools to organize their code as they wish, rather than imposing constraints like requiring many small components to be in separate files. Java for example also had a similar problem (dunno if more recent versions fixed it) - you can only have one class per file, which creates a huge mess if you like having many small files. C# does not have this limitation and as a result C# codebases can be much tidier than Java codebases.
Windows Version: Microsoft Windows [Version 10.0.14393]
MSBuild Version : Microsoft (R)-Buildmodul, Version 15.1.1012.6693
The project is written in C.
In the *.vcxproj files of this project there is a lot of code in like this
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
[do some stuff]
</ImportGroup>
for all configurations, 'Debug|Win32', 'Release|Win32', 'Debug|x64', 'Release|x64'. But I will have the same configuration for all combinations, therefore I do not want to write it 4 times making my project file 3 times longer and less readable .
Is there a shortcut like Condition="'$(Configuration)|$(Platform)'=='Any Configuration|Any Architecture'?
The standard way of doing this would be using 'property sheets'; more concrete: one property sheet with the common options which gets imported by all platform/configuration combinations. Some reasons to choose this approach:
it exactly addresses your "I will have the same configuration for all combinations, therefore I do not want to write it 4 times making my project file 3 times longer and less readable" requirement, and more: it keeps the common options in one single file, which can also be resued by other projects (which is really the number 1 selling point if you have multiple projects and want the same options for them)
it has user interface support for editing (though it's no problem if you'd want to manually edit the vcxproj to add it)
it keeps the standard project structure intact, so still allows for per-configuration and per-platform modifications should you need those
property sheets are just msbuild files like any other and as such can Import other files so you can create hierarchies with them, do things like having one master file which based on application type (exe/dll) sets different output paths and so on
You can remove the Condition attribute and have the ImportGroup being applied for every configuration.
I know i can use 7z or winrar but i want to learn this for myself.
How would i implement a self extracting archive? I can use C# or C++ but let me run down the problem.
When i open the exe i need some kind of GUI asking where to extract the files. Once the user says ok I should obviously extract them. I implemented a simple example in C# winforms already BUT my problem is HOW do i get the filenames and binary of the files into an exe?
One upon a time i ask Is it safe to add extra data to end of exe? and the answer suggested if i just add data to the end of the exe it may be picked up by a virus scanner. Now its pretty easy to write the length of the archive as the last 4bytes and just append the data to my generic exe and i do believe my process can read my own exe so this could work. But it feels hacky and i rather not have people accuse me of writing virus just because i am using this technique. Whats the proper way to implement this?
Note: I checked the self-extracting tag and many of the question is how to manipulate self extracting and not how to implement. Except this one which is asking something else Self-extracting self-checking executable
-edit- I made two self extracting with 7z and compared them. It looks like... well it IS the 7z.sfx file but with a regular 7z archive appended. So... there is nothing wrong with doing this? Is there a better way? I'm targeting windows and can use the C# compiler to help but i don't know how much extra work or how difficult it may be programmatically and maybe adding data to end of exe isnt bad?
It is possible. I used the following technique once, when we needed to distribute updates for the application, but the computers were configured so that the end user had no permissions to change application files. The update was supposed to log on to administrator account and update required files (so we came across identical problem: how to distribute many files as a single executable).
The solution were file resources in C#. All you need to do is:
Create a resource file in your C# project (file ending with .resx).
Add new resource of type "file". You can easily add existing files as byte[] resources.
In program you can simply extract resource as file:
System.IO.FileStream file = new System.IO.FileStream("C:\\PathToFile",
System.IO.FileMode.OpenOrCreate);
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(file);
writer.Write(UpdateApplication.Data.DataValue, 0, UpdateApplication.Data.DataValue.Length);
(Here UpdateApplication.Data denotes binary resource).
Our solution lacked compression, but I believe this is easily achieved with libraries such as C#ZipLib.
I hope this solution is virus-scanner-safe, as this method creates complete, valid executable file.
I've always backed up all my source codes into .zip files and put it in my usb drive and uploaded to my server somewhere else in the world.. however I only do this once every two weeks, because my project is a little big.
Right now my project directories (I have a few of them) contains a hierarchy of c++ files in it, and interspersed with them are .o files which would make backing up take a while if not ignored.
What tools exist out there that will let me just back things up efficiently, conveniently and lets me specify which file types to back up (lots of .png, .jpg and some text types in there), and which directories to be ignored (esp. the build dirs)?
Or is there any ingenious methods out there that people use?
Though not a backup solution, a version control manager on a remote server responds to most of your needs:
only changes are saved, not the whole project
you can filter out what you don't want to save
Moreover, you can create archives of your repository for true backup purposes.
If you want to learn about version control, take a look at Eric Sink's weblog, in particular:
Source Control HOWTO, for the basics of source control
Mercurial, Subversion, and Wesley Snipes for the links to articles on distributed version control systems
I use dropbox, im a single developer developing software. In some projects I work out from my dropbox which means they synchronize every time i build. Other projects i copy the source code there my self. But most important is that i can work on all my computers with dropbox installed on them... works for my simple needs
Agree with mouviciel. If you do not want that, consider rsync or unison to efficiently keep an up-to-date copy, be it on the same or a different machine.
In the lower left corner of LINQPad, there is an area for display queries. One tab is My Queries and another one for Samples. I could not find a way to add more than one folder like in My Queries, just like one in Samples tab. I tried right click and checked all the menu items.
I'm not sure if I can change XML settings to include more than one folders in My Queries to organize my codes.
How can I have multiple query folders in LINQPad?
The answer I am adding here does not resolve the implicit question of, "how does one have multiple root level folders in LINQPad." However, I think it provides a solution to the question of, how "to include more than one folders [sic] in My Queries to organize my codes?"
Technique 1 - Just add folders (arguably worse than Technique 2)
You can have multiple sub folders under the My Queries folder, and they will all show up. This adds the benefit of being able to organize your queries a bit, with the downside being the fact that you will probably include a lot more files and folders than you intend to:
To add folders, just navigate to your My Queries folder in File Explorer, and add a new folder. Refreshing your My Queries pane will the display the new folder.
Technique 2 - Symbolic Links
You can achieve a similar result as Technique 1 by using symbolic links. The benefit to this approach is that you can link just the folders that you want (e.g. folders that contain scripts), while leaving everything else alone:
Please note that creating symbolic links typically requires administrative privileges on a computer.
Creating symbolic links is easy with Powershell:
# By not changing the value for "Path," this will create a symbolic link in the current folder
# that is named whatever value is given for "Name," and it will be pointed to whatever value
# "Value" is set to.
new-item -ItemType SymbolicLink -Path . -Name "ExampleSharedScripts" -Value "Path to actual folder"
The difference between the two techniques
To explain what is really different between the two techniques, I'll explain the folder structure from the pictures a bit more:
In technique 1, an entire repository is shown due to the fact that the entire repository is kept under the My Queries folder. In technique 2, my repository is stored somewhere else entirely, but I have added a symbolic link in my My Queries folder that points to the queries contained within the repository itself. Technique 2 allows me to store my repositories in a more appropriate place, while still allowing for the convenience of having scripts show up in the My Queries pane of LINQPad.
Other reading
A couple of blog posts have been put out on the internet with some tips and tricks around LINQPad. This blog post from Dan Clarke talks about how he creates symbolic links to manage his scripts (he also lists some other tricks).
There's no way to display more than one root folder in 'My Queries' at present. If you like, add a suggestion at linqpad.uservoice.com so we can guage demand.
LinqPad does not show empty folders in the tree so if you only created a folder you will also need to add a query for this to show in the tree. This has been something that has tripped me a couple of times.