How to use the NFS Client c # Library,

Source: Internet
Author: User

How to use the NFS Client c # Library,

Download the class library

I add a wiki page that explains how to use the NFS Client c #. net library in your project.

NekoDrive uses a Library written in C # on. NET 2.0. that wraps the C ++ NFS implementation. in order to use this library in your project download NekoDrive and copy in your project NekoDrive. NFS. dll, NFSv2.dll and NFSv3.dll. add a reference in your project to NekoDrive. NFS. dll. don't forget to include NFSv2.dll and NFSv3.dll as a content to deploy.

You download this library here:

Http://code.google.com/p/nekodrive/

EXAMPLE 1-CONNECT TO NFS SERVER AND GET THE EXPORTED DEVICES
using System;using System.Collections.Generic;using System.Text;using System.Net;using NekoDrive.NFS;using NekoDrive.NFS.Wrappers;namespace Example1{   class Program    {        static void Main(string[] args)        {            using(NFS nfs = new NFS(NFS.NFSVersion.v2))            {                if (nfs.Connect(IPAddress.Parse("161.55.201.250")) == NFSResult.NFS_SUCCESS)                {                    foreach(string device in nfs.GetExportedDevices())                        Console.WriteLine(device);                    nfs.Disconnect();                }            }        }    }}
EXAMPLE 2-connect to nfs server, MOUNT THE FIRST EXPORTED DEVICE AND GET THE FILE LIST
namespace Example2{    class Program    {        static void Main(string[] args)        {            using(NFS nfs = new NFS(NFS.NFSVersion.v2))            {                if (nfs.Connect(IPAddress.Parse("161.55.201.250")) == NFSResult.NFS_SUCCESS)                {                    List devices = nfs.GetExportedDevices();                    if(devices.Count > 0)                    {                        if(nfs.MountDevice(devices[0]) == NFSResult.NFS_SUCCESS)                        {                            foreach(string item in nfs.GetItemList())                            {                                NFSAttributes attrib = nfs.GetItemAttributes(item);                                Console.WriteLine(item + " " + attrib.cdateTime.ToString() + " " + attrib.size);                            }                            nfs.UnMountDevice();                        }                    }                    nfs.Disconnect();                }            }        }    }}
EXAMPLE 3-connect to nfs server, mount the first exported device and download a file in the root folder (.)
namespace Example3{    class Program    {        static void Main(string[] args)        {            using(NFS nfs = new NFS(NFS.NFSVersion.v2))            {                if (nfs.Connect(IPAddress.Parse("161.55.201.250")) == NFSResult.NFS_SUCCESS)                {                    List devices = nfs.GetExportedDevices();                    if(devices.Count > 0)                    {                        if(nfs.MountDevice(devices[0]) == NFSResult.NFS_SUCCESS)                        {                            if(nfs.Read("test.txt", ".", @"c:\test.txt") != NFSResult.NFS_SUCCESS)                                Console.WriteLine(nfs.GetLastError());                            nfs.UnMountDevice();                        }                    }                    nfs.Disconnect();                }            }        }    }}
EXAMPLE 4-connect to nfs server, mount the first exported device and upload a file in the "TEST/SUB" SUBFOLDER
namespace Example4{    class Program    {        static void Main(string[] args)        {            using(NFS nfs = new NFS(NFS.NFSVersion.v2))            {                if (nfs.Connect(IPAddress.Parse("161.55.201.250")) == NFSResult.NFS_SUCCESS)                {                    List devices = nfs.GetExportedDevices();                    if(devices.Count > 0)                    {                        if(nfs.MountDevice(devices[0]) == NFSResult.NFS_SUCCESS)                        {                            if(nfs.Write("test.txt", "test/sub", @"c:\test.txt") != NFSResult.NFS_SUCCESS)                                Console.WriteLine(nfs.GetLastError());                            nfs.UnMountDevice();                        }                    }                    nfs.Disconnect();                }            }        }    }}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.