I want to bind a file to a folder so that when the file is moved/copied/deleted the folder is also automatically moved/copied/deleted along with the file (Similar to how html files are linked to the folder containing their resources)
At the moment this behaviour is activated only for html files and their corresponding "htmlFilename_files" folders. Is there a way to register another file extension for such behavior? Or is there a hack or feature that provides similar behavior? Thanks.
Even for HTML this behavior is specific to Explorer.
The problem is that there's no "copy" operation on filesystem level (and Move operation is different from what you see in user mode).
Technically you can create a filesystem filter driver and track RenameOrMove and Delete operations on some file, then perform some operation with the directory. But this won't work for copy which is a sequence of "read" + "write" operations and you would have hard time matching reads and writes (but, well, I can think of some ways to track copying using filter driver as well). You can create a filter driver yourself, but this requires C programming and special knowledge. You can write a driver yourself (read MSDN article) or use our CallbackFilter product (it provides a pre-created driver and .NET API for integration with your software).
If data file is yours, it makes sense to keep all files in one virtual container - this can be MHT file (HTML + supplementary files are combined into MHT by Internet Explorer), ZIP archive or SolFS storage (SolFS is our virtual file system product). Then there's only one file for the user to manage and your application has all files inside.
If you need to let external applications access files in the container, then the virtual disk can be created - such disk will expose contents of the container. Contents of any container can be exposed as a virtual disk using now-dead Dokan or our Callback File System product.
Related
There is a feature in OneDrive that you can see a file that is on the OneDrive site on your system without actually having that file in your system. And when you double click on that file, that file starts to download and you can see its contents.
I want to implement such a possibility with C#.
I have a site where files are uploaded.
I download the files from there and put them in a folder on my C drive.
But I want that file not to be downloaded until it is double-clicked, something similar to OneDrive.
What should I do?
I compared the FileInfo of these two files, but I didn't see any difference and I couldn't find a solution for this problem.
This is a virtual filesystem implemented using a file system driver.
There are multiple ways to implement this feature using C/C++.
But in your case, using C# means you should use third-party libraries to create a virtual files system.
There is a library called Dokan, which lets you implement a full-featured virtual file system, and you have complete control over its behaviour in your C# project.
it called "Windows Shell namespace"
https://learn.microsoft.com/en-us/windows/win32/shell/namespace-intro
i used EZNameSpace Wrapper for handling this.
there is another library called "CBFS Shell" (formerly shelboost) that you can use.
You could create a dummy file that appears to be correct but is really just a pointer to some code that downloads the correct file. Then use File.Move or File.Copy to replace the dummy file with the actual file.
for a small project, I would like to be able to store additional information about a file and keep that information with the file even when it is moved.
The additional information will be stored in a XML-file. To keep the file and its description together, I thought about using ZIP-archives without any compression, but I would like these ZIP-archives to behave just like the original files (i.e. if the original file was a video file, a double-click on the archive should open the file in the media player). This requires me to write a small program that handles this 'new' file format.
However, I have not found a solution that would allow me to open the file without first extracting the file from the archive (even without compression), which does take some time and is not what I want.
My questions are: Is there a library (for C# or C/C++) that allows me to open a zip file and directly play/open a file inside it wihout extracting the archive? Or is there an easier way to implement what I need (maybe I am thinking in the wrong direction)?
Windows already allows you to store additional metadata about a shell item (including files) through the Windows Property System.
The Windows API Code Pack includes samples and documentation on how to work with many of the native OS capabilities, including the Property System.
The following excerpts come from the PropertyEdit sample.
To get a file's property by name:
var myObject= ShellObject.FromParsingName(fileName);
IShellProperty prop = myObject.Properties.GetProperty(propertyName);
To set a string property:
if (prop.ValueType == typeof(string))
{
(prop as ShellProperty<string>).Value = value;
}
If you don't want to use the Property System, you can use NTFS alternate data streams to store additional info about a file. There is no direct support for ADS in .NET but a simple search returns multiple wrappers, libraries and SO questions about them, eg NTFS - Alternate Data Streams
I'm working on a WPF project which is in charge to display a picture library.
The pictures are stored on folders.
I would like to know if there is a way to encrypt the folders and the pictures to protect the files (the user shouldn't see the files), but I want to keep the possibility to browse these folders by code to build my library.
The best way that I can think of is to store the files and folders in a Zip archive with a password. Zip files are supported natively by Windows. There are plenty of options for supporting zip files, including framework options and outboard libraries.
Note that this doesn't really protect the files from user tampering; it merely hides them from casual observers. Also, there may be a speed penalty; you should use the fastest possible options for compression.
you can use Zip archive and Another way:
you can add another project project(Library)into your main solution,add your image folders into your application and set their build action property to resource,with that,your images will store in an Dll and for can access them from Dll.i tried it before follow this link:
get-folder-address-in-dll
Im looking for methods to combine files including their name and relative path into one single file. A folder disguised as a file. I don't need any compression or encryption. Just the file data including some binary metadata attached to each file.
It would be great if this file was possible to open/inspect/unpack with a standard file browser in Windows such as with regular zip-files.
Yes I could use zip. But I'm researching alternatives and I would prefer a simple method I could implement myself in C#/.NET.
UPDATE
I've researched this some more and came across Microsoft's Structured Storage format. It looked promising at first but it seemes to be an obsolete format, replaced with the Open Package Format. And then I found out about the TAR-format. It seemes to be the most basic format. But I'm not sure yet if I can add any custom metadata to the entries with TAR.
UPDATE
I went with DotNetZip at the end anyway...
Why not use zip? You can use a third party library, like dotnetzip, to make the code easy to write. And, as you mentioned, Windows handles zip files well.
If you have specific reason to search an alternative to ZIP, take a look on virtual file systems, eg. CodeBase File System or our Solid File System. Solid File System lets you add alternate data streams (like in NTFS) or tags (small chunks of binary or text data) to each file or directory. And with OS edition of SolFS you can make the filesystem visible to Windows (including Explorer and third-party applications).
I must admit that while virtual file systems are easy to use (easier than ZIP), they are commercial products (I didn't see free virtual file system implementations yet).
I am creating an application that uses Quartz.NET to automatically download and upload files to various sources (HTTP, FTP and Network paths) based upon a regular exprsesion. Users can select multiple paths for each download and upload operation, so a typical job may be to download files from a http server, and also download from an ftp server, and upload all files to a network path.
Currently, I am downloading all files from all the download sources, and storing them in a folder (With the name of a folder being a GUID specific to that job). Then for the upload stage, it will simply read all files from that directory, and upload them to the path, which is great.
Problem is, for specific paths, the user may request these to be deleted after upload has completed, which is an issue as how can I find out where a file come from in a folder? I've been trying to think of ways around this, such as creating folders for each download path, but I'd need to check for duplicate names on download rather than upload, plus I'd need to merge both subfolders...etc!
Can anyone offer any ideas? Many thanks
Think about this in a object oriented manner.
Create a class like this
public class File
{
public string source;
public string destination;
public bool deleteSource; //if true delete the source after the copy
}
Now create a list of File classes like List<File> files and keep that as variable in your app.
Add objects to the list in the start and then traverse the list and copy / upload files. Check the deleteSource property and if it is true delete the file after the copy operation.
This is a basic idea and expand this class as required.
What I want to stress is that think of a problem in the object oriented way and start designing
When you download a file, can you create a separate text file that contains the source and destination paths? That way you can read in that mapping later and process them as necessary based on the source.