Recently in the software to prepare the function, the background using node for development. problem
In the process of development, you need to obtain version information and name of the software, but the method of node getting file information Fs.stats method is not able to meet the requirements. We need to get to the contents of the following diagram
The version of the product and the name of the product. But C # is available with the appropriate API. Solve
Find the corresponding development wrote a DLL, specifically to get the information of the file. The code is as follows:
The simple thing about the code is to return an object with the name of the file and the version number. Here's a new feature of. NET, Task,async, as to why encapsulation into Func edge is what
Edge is a bridging technology that implements NODEJS and. NET interoperability in the process, and can use. NET code and libraries in Nodejs, or you can use Nodejs code in. NET programs.
Edge operation requires. netframework4.5, which uses the. NET task, async, await mechanism to match the Nodejs event model. Essentially, it connects the V8 engine and the. NET/MONOCLR runtime while supporting Windows, MacOS, and Linux. It also supports various scripting languages running on the. NET CLR. By bridging technology in this process, the various class libraries and other technologies on either side can be nodejs, such as using the. NET Image processing library GDI +, directly manipulating the SQL Server database with ado.net, or even directly calling WinForm code to implement the desktop UI program, and so on.
Introduction to the concept of a bunch of actually we still see how to use it.
var Objdll = Edge.func ({
assemblyfile: './libs/fileinfo.dll ',//c# file path
typeName: ' Fileinfo.fileinfotask ',// namespace + class name
methodname: ' GetFileInfo '//Method name
};
var fileInfo = Objdll (Path.resolve ('./public/attachments/' + req.query.fileName), true);
The above can solve our problem.