Skip to content

This is the repository for the NuGet package called SharedDriveConnection. This package is used to connect to a shared network drive with credentails.

Notifications You must be signed in to change notification settings

SebastianDevelops/SharedDriveConnection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SharedDriveConnection NuGet Package

SharedDriveConnection is a simple .NET library that facilitates connecting to a network share with authentication. This library provides a DriveConnect class, allowing users to establish and manage network connections effortlessly.

Getting Started

Installation

To use this library, you can install it via NuGet Package Manager Console:

Install-Package SharedDriveConnection

Usage

  1. Initialize DriveConnect:

    using SharedDriveConnection;
    // Specify the network share path and credentials
    string networkPath = "\\server\\share";
    NetworkCredential credentials = new NetworkCredential("username", "password");
    
    // Create an instance of DriveConnect
    using (DriveConnect driveConnect = new DriveConnect(networkPath, credentials))
    {
        // Your code here
    }
  2. Dispose of the Connection:

    The connection will be automatically disposed of when leaving the using block. However, you can manually dispose of it using the Dispose method:

    driveConnect.Dispose();

Documentation

DriveConnect Class

Constructors

  • DriveConnect(string networkName, NetworkCredential credentials): Initializes a new instance of the DriveConnect class.

Events

  • Disposed: Occurs when the instance has been disposed.

Methods

  • Dispose(): Performs tasks associated with freeing, releasing, or resetting unmanaged resources.

Objects needed for Win32 functions

  • NetResource: Represents details of the proposed connection.
  • ResourceScope: Enumerates the resource scope.
  • ResourceType: Enumerates the resource type.
  • ResourceDisplaytype: Enumerates the resource display type.

Example

using SharedDriveConnection;

// Specify the network share path and credentials
string networkPath = "\\server\\share";
NetworkCredential credentials = new NetworkCredential("username", "password");

// Create an instance of DriveConnect
using (DriveConnect driveConnect = new DriveConnect(networkPath, credentials))
{
    // Your code here
}

For more details on the Win32 functions used, refer to the Microsoft documentation.

Contributions

Contributions are welcome! Feel free to submit issues or pull requests.

License

This library is licensed under the MIT License.

About

This is the repository for the NuGet package called SharedDriveConnection. This package is used to connect to a shared network drive with credentails.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages